[英]QueryDSL to get any entities in a collection of another entity
I'm using JPA with Hibernate and QueryDSL (v.4.0.5). 我正在将JPA与Hibernate和QueryDSL(v.4.0.5)一起使用。 I have this entity:
我有这个实体:
package com.test.model.entity;
@Entity
public class Article {
@Id
private Long id;
@ManyToMany(fetch = LAZY, cascade = DETACH)
private Set<Tag> tags;
}
How can I find all the articles matching a given set of Tag
s? 如何找到与给定
Tag
集合匹配的所有文章? I think I should start as follows: 我认为我应该开始如下:
public BooleanExpression hasTag(Set<Tag> tags){
final QArticle article = QArticle.article;
return article.tags.any().eqAny(ce);
}
where ce
should be a CollectionExpression
. ce
应该是CollectionExpression
。 Clearly I have no idea how to set this. 显然我不知道该如何设置。
Any solution? 有什么办法吗?
Did you try 你试过了吗
public BooleanExpression hasTag(Set<Tag> tags){
QArticle article = QArticle.article;
return article.tags.any().in(tags);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.