【发布时间】:2015-08-26 20:21:53
【问题描述】:
我正在使用 Hibernate 3.6,并且我有一个类 Shop,其中包含一个 Set
<set cascade="all-delete-orphan" lazy="true" name="alternateCodes"
table="shops_alternateCodes">
<key column="SHOP_ID" not-null="true"/>
<element column="CODE" length="32" not-null="true" type="string"
unique="true"/>
</set>
我想建立一个标准来搜索作为包含一些字符串的替代代码的商店。
HQL 等价物是这样的:
from Shop s join s.alternateCodes c where c=?
如何使用标准 API 来表达这一点?
提前致谢
附言
我试过这个:
teria = getPm().createCriteria(Shop.class);
...
teria.createAlias("alternateCodes", "acode");
teria.add(Restrictions.eq("acode", code));
当然,它不起作用。
【问题讨论】:
标签: hibernate hibernate-criteria