【发布时间】:2017-12-22 02:17:44
【问题描述】:
我得到了以下数据结构
@Entity
public class Publication {
private Map<Integer, Author> authors;
// more stuff
}
@Entity
public class Author {
private String name;
// more stuff
}
我正在寻找一个查询 dsl 谓词,它提供我的所有出版物,其中任何 Author.name 包含某个字符串,例如“汉斯”
我试过了:
QPublication publication = QPublication.publication;
QAuthor author = QAuthor.author;
publication.authors.containsValue(JPAExpressions.selectFrom(author).where(author.lastName.containsIgnoreCase("Hans")));
但是,如果有多个作者的名字中包含“Hans”,这会报错。有没有像 publication.authors.anyValue().name.equalsIgrnoreCase("Hans") 这样的东西?
【问题讨论】:
标签: java jpa spring-data querydsl