我有以下域名模型:
@Entity
public class Sample {
// id and other stuff
private boolean deleted;
private Set<Occurrence> occurrences;
// Constructors, getter and setter
}
@Entity
public class Occurrence {
// id and other stuff
private boolean deleted;
private Classification classification;
// Constructors, getter and setter
}
@Entity
public class Classification {
private int id;
// other stuff
}
我想在QueryDSL和Spring Data JPA中找到所有未删除且包含发生的样本,不会被删除,并且包含一个id为47的分类。
我已经为未删除的样本创建了一个BooleanExpression:qSample.deleted.isFalse()
和一个具有特定分类ID的非删除事件的SubQuery:
JPASubQuery occurrenceSubQuery = new JPASubQuery();
QOccurrence qOccurrence = QOccurrence.occurrence;
occurrenceSubQuery.from().where(
qOccurrence.in(qSample.occurrences),
qOccurrence.deleted.isFalse(),
qOccurrence.classification.id
.eq(queryId));
缺少的是:如何将这些部分组合到spring数据存储库的谓词中?
此致
丹尼尔
答案 0 :(得分:0)
您可以使用
com.mysema.query.support.Expressions.allOf(...)
或
a.and(b).and(c)...