小编Kev*_*vin的帖子

使用Spring DATA-JPA的Set <?>的IN运算符进行JPA标准查询

在我的应用程序中,两个实体之间具有以下映射:

@Entity
public class Applicant {
     private Integer id;
     ....
     private Set<Document> documents;

     ... Getters and Setters ...

     @OneToMany(fetch = FetchType.LAZY, mappedBy = "applicant", cascade = CascadeType.ALL)
     public Set<Document> getDocuments() {
     return documents;
     }

    public Applicant setDocuments(Set<Document> documents) {
        this.documents = documents;
        return this;
    }
}
Run Code Online (Sandbox Code Playgroud)

和文件:

public class Document {

    private Long id;
    private Applicant applicant;

    ... Getters and Setters ...

    @ManyToOne
    public Applicant getApplicant() {
        return applicant;
    }

    public Document setApplicant(Applicant applicant) {
        this.applicant = applicant;
        return this; …
Run Code Online (Sandbox Code Playgroud)

java spring jpa criteriaquery spring-data-jpa

1
推荐指数
1
解决办法
5492
查看次数

标签 统计

criteriaquery ×1

java ×1

jpa ×1

spring ×1

spring-data-jpa ×1