Collection.contains(Enum.Value) in HQL?

蓝咒 提交于 2019-12-04 05:15:42
Arthur Ronald

You should map as follows

@CollectionOfElements
@Enumerated(EnumType.STRING)
@JoinTable(
    name="BAR_TABLE",
    joinColumns=@JoinColumn(name="FOO_ID")
)
public Set<Bar> getBarSet() {
    return this.BarSet;
}

And your HQL looks like

select distinc Foo _foo inner join fetch _foo.barSet bar where bar = :selectedBar

query.setParameter("selectedBar", Bar.A);

query.list();

Here you can see how to map

regards,

You can do this

"from Foo as foo where :selectedBar member of foo.barSet"

select mother from Cat as mother, Cat as kit where kit in elements(foo.kittens)

docs.jboss.org

whiskeysierra

I usually prefer storing enum sets as bitsets in the database. It's blazing fast and requires one (!) single column. I don't know how HQL handles bit operations but you can register your own.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!