开发者

How can I select objects by list size in HQL?

开发者 https://www.devze.com 2023-04-07 02:46 出处:网络
My entity is defined like this: public c开发者_JS百科lass Entity implements Serializeable { @ManyToMany(mappedBy=\"entities\")

My entity is defined like this:

public c开发者_JS百科lass Entity implements Serializeable {
      @ManyToMany(mappedBy="entities")
      private List<OtherEntity> otherEntities;

}

How can I select in HQL all Entities which have more than one OtherEntity?


I think this should work. This will generate a SQL with a subquery - not fetch it and filter it in memory.

from Entity e where e.otherEntities.size > 1
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号