JPA查询方法按List中的元素查找?

时间:2016-12-21 09:00:25

标签: jpa

我有以下两个实体(联系和参与,由ManyToMany关系链接):

@Entity
public class Contact {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @Column(nullable=false)
    private String firstName;
    @Column(nullable=false)
    private String lastName;

    @ManyToOne
    private Company company;


    @ManyToMany(fetch=FetchType.EAGER)
    private List<Participation> participations;
}


@Entity
public class Participation {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    private Company company;

    private Status status;
}

我无法弄清楚如何在其列表中获得具有特定参与的联系人。我应该通过具有特定JPA存储库方法的联系人查找(findBy ...)?或者我是否必须通过使用联系人和参与ID(ManyToMany)创建的表格查看?

谢谢!

0 个答案:

没有答案