Hello,
I am trying to run the query below, which is supposed to return a list of "Group" objects. When I run it, I get a "Object" that contains a Group and a UserGroup object.
I need it to run a Group - what am I doing wrong that is preventing this from coming back a Group object?
Thanks
Code:
Session session = sessionFactory.getCurrentSession();
Query qry = session.createQuery("from Group as grp " +
" join grp.userGroups as userGroup " +
" where userGroup.user.userId = :userId ");
qry.setString("userId", userId);
List<Group> result = (List<Group>)qry.list();
if (result == null || result.size() == 0)
return null;
return result;
Hibernate version: 3.2
Mapping documents:Code:
<hibernate-mapping>
<class name="org.openiam.idm.srvc.grp.dto.Group" table="GRP" >
<comment></comment>
<id name="grpId" type="string">
<column name="GRP_ID" length="20" />
<generator class="assigned" />
</id>
<property name="grpName" type="string">
<column name="GRP_NAME" length="40">
<comment></comment>
</column>
</property>
.....
<set name="userGroups" cascade="all-delete-orphan" lazy="true" fetch="join">
<key>
<column name="GRP_ID" length="20" not-null="true" />
</key>
<one-to-many class="org.openiam.idm.srvc.grp.dto.UserGroup" />
</set>
Code:
<hibernate-mapping>
<class name="org.openiam.idm.srvc.grp.dto.UserGroup" table="USER_GRP" >
<comment></comment>
<id name="userGrpId" type="string">
<column name="USER_GRP_ID" length="20" />
<generator class="org.openiam.base.id.SequenceGenerator">
<param name="table">sequence_gen</param>
<param name="column">next_id</param>
<param name="attribute">USER_GRP_ID</param>
</generator>
</id>
......
<many-to-one name="user" class="org.openiam.idm.srvc.user.dto.User" fetch="join">
<column name="USER_ID" length="20" not-null="true">
<comment></comment>
</column>
</many-to-one>