JPA query problem

beginners, if you encounter a problem with JPA query, please do not hesitate to give us your advice!

@ Entity
@ Table (name = "person")
public class User {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "person_id")
private Long person_id;

@Column(name = "name")
private String name;

@OneToMany(mappedBy = "person", cascade = CascadeType.ALL)
private Set<Skill> skills = new HashSet<>();


/**
 * Returns a set containing all skills owned by this user.
 */
@Override    
public Set<Skill> getSkills() {
    return skills;
}

/**
 * Adds the specified skill to the set of skills owned by this user.
 */
public void addSkill(Skill skill) {
    skills.add(skill);
}

/ * *

 * Required by JPA, should not be used.
 */
protected User() {
}

public User (String name) {

this.name = name;
    person_id = BeanFactory.getBean(BusinessIdGenerator.class).generatePerson_id();
}

public Long getPerson_id() {
    return person_id;
}

public void setPerson_id(Long person_id) {
    this.person_id = person_id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}


@Override
public int hashCode() {
    return person_id.hashCode();
}

@Override
public boolean equals(Object object) {
    if (!(object instanceof User)) {
        return false;
    }
    User other = (User)object;
    return this.person_id.equals(other.person_id);
}

@Override
public String toString() {
    return Util.toString(this);
}

}

@ Entity
@ Table (name = "skills")
public class Skill {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = skill_id")
private Long skill_id;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "person_id")
private User user;

@Column(name = "name")
private String name;

/**
 * Required by JPA, should not be used.
 */
protected Skill() {
}

public Skill(User user,Long skill_id) {           
    this.user = user;
    skill_id = BeanFactory.getBean(BusinessIdGenerator.class).generateSkill_id();
}

@Override
public Long getSkill_id() {
    return skill_id;
}

}

now if a recruiter wants to find a group of users who match one or some of these skills based on a set of skills (List < Skill > requiredSkills) (Set < User > users), can I add the following method to UserRepository? If it is not feasible, do you have any suggestions?

List < User > findBySkillsIn (List < Skill > requiredSkills);

Jun.24,2022
Menu