使用list在HQL中映射表

时间:2014-07-20 19:35:08

标签: hql

我使用HQL在报表应用程序中创建查询,我的查询如下所示:

from Identity i, Bundle b, IdentityBundles aib
           WHERE b.name LIKE 'DYP%' AND i.bundleSummary LIKE 'DYP%' 
           AND i.id = aib.identityId AND b.id = aib.bundle

我尝试运行此查询时出现下一个错误:

IdentityBundles is not mapped [select count(*) from sailpoint.object.Identity i, sailpoint.object.Bundle b, IdentityBundles aib

看起来没有映射到IdentityBundles

我在应用程序的jar文件中注意到的唯一想法是这个列表名称(在Identity.hbm.xml文件中创建),其中包含表IdentityBundles的属性

 list name="bundles" table="IdentityBundles"
   cascade="persist,merge,save-update">
   key column="identityId"
   list-index column="idx"
   many-to-many column="bundle" class="sailpoint.object.Bundle"
 list

我可以使用此列表映射表,还是需要创建类和hbm.xml文件?

1 个答案:

答案 0 :(得分:0)

Hibernate适用于映射。您正在尝试指定联接,因为这些联接已经映射到您的域对象中,您不需要这样做。请改用域对象属性,Hibernate将为您提取它们。

from Identity i 
    join i.bundles b
    where b.name like ...