Hello,
I have the query below which returns a collection "Objects" instead of "Group". Any ideas on what I maybe doing wrong? When I look at the returned objects in a debugger, its actually an array containing 1 Group and 1 GroupRole object.
Code:
Session session = sessionFactory.getCurrentSession();
Query qry = session.createQuery(" from Group grp " +
" inner join grp.groupRoles as groupRole " +
" where groupRole.role.serviceId = :serviceId and " +
" groupRole.role.roleId = :roleId ");
qry.setString("serviceId", serviceId);
qry.setString("roleId", roleId);
List<Group> results = (List<Group>)qry.list();
Maps:
Group:
Code:
<hibernate-mapping>
<class name="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>
<property name="createDate" type="timestamp">
<column name="CREATE_DATE" length="19">
<comment></comment>
</column>
</property>
<property name="createdBy" type="string">
<column name="CREATED_BY" length="20">
<comment></comment>
</column>
</property>
<property name="companyId" type="string">
<column name="COMPANY_ID" length="20">
<comment></comment>
</column>
</property>
<property name="parentGrpId" type="string">
<column name="PARENT_GRP_ID" length="20">
<comment></comment>
</column>
</property>
<set name="groupRoles" cascade="all-delete-orphan" lazy="true" inverse="true">
<key>
<column name="GRP_ID" length="20" not-null="true">
<comment></comment>
</column>
</key>
<one-to-many class="GroupRole" />
</set>
</class>
</hibernate-mapping>
GroupRole:
Code:
<hibernate-mapping>
<class name="GroupRole" table="GRP_ROLE" >
<comment></comment>
<id name="grpRoleId" type="string">
<column name="GRP_ROLE_ID" length="20" />
<generator class="SequenceGenerator">
<param name="table">sequence_gen</param>
<param name="column">next_id</param>
<param name="attribute">GRP_ROLE_ID</param>
</generator>
</id>
<many-to-one name="role" class="Role" fetch="select">
<column name="ROLE_ID" length="20" not-null="true">
<comment></comment>
</column>
</many-to-one>
<many-to-one name="group" class=".Group" fetch="select">
<column name="GRP_ID" length="20" not-null="true">
<comment></comment>
</column>
</many-to-one>
<property name="serviceId" type="string">
<column name="SERVICE_ID" length="20" not-null="true">
<comment></comment>
</column>
</property>
<property name="createDate" type="timestamp">
<column name="CREATE_DATE" length="19">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>