Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hallo support,
I have an hibernate object named CnePlatformEdition where a Set of CnePlatformComponents is defined. In the hibernate object CnePlatformComponents another object CnePlatformPackage is included. See concerned mappings below)
|CnePlatformEdition| -- Set --> | CnePlatformComponents | -- Component --> | CnePlatformPackage |
I tried to get the properties of all objects by running following
criteria statement:
tx = sessionLocal.beginTransaction();
Criteria criteria = sessionLocal.createCriteria(CnePlatformEdition.class);
criteria.createAlias("platformComponents","platformComponents"); criteria.createAlias("platformComponents.cnePlatformPackage","cnePlatformPackage");
criteria.add(Restrictions.eq("platformEditionId", platformEditionId));
criteria.setFetchMode("platformComponents", FetchMode.JOIN);
criteria.setFetchMode("cnePlatformPackage", FetchMode.JOIN);
criteria.addOrder(Order.asc("cnePlatformPackage.packageName"));
criteria.addOrder(Order.asc("cnePlatformPackage.packageRelease"));
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
CnePlatformEdition result = (CnePlatformEdition) criteria.uniqueResult();
tx.commit();
The criteria query works fine and I can run the following produced statement (JOIN) on my oracle database without any errors:
select this_.PF_ID as PF1_18_2_, this_.PF_NAME as PF2_18_2_, this_.PF_RELEASE as PF3_18_2_, this_.PF_STATUS as PF4_18_2_, platformco1_.PFCOMP_ID as PFCOMP1_17_0_, platformco1_.PF_ID as PF2_17_0_, platformco1_.PFCOMP_TYPE as PFCOMP3_17_0_, platformco1_.PFCOMP_SEQNO as PFCOMP4_17_0_, platformco1_.PFPKG_ID as PFPKG5_17_0_, platformco1_.PFCOMP_REMARK as PFCOMP6_17_0_, cneplatfor2_.PFPKG_ID as PFPKG1_20_1_, cneplatfor2_.PFPKG_NAME as PFPKG2_20_1_, cneplatfor2_.PFPKG_RELEASE as PFPKG3_20_1_ from CNE_ADM.CNE_T_PF_EDITIONS this_ inner join CNE_ADM.CNE_T_PF_COMPONENTS platformco1_ on this_.PF_ID=platformco1_.PF_ID inner join CNE_ADM.CNE_T_PF_PACKAGES cneplatfor2_ on platformco1_.PFPKG_ID=cneplatfor2_.PFPKG_ID where this_.PF_ID=8 order by cneplatfor2_.PFPKG_NAME asc, cneplatfor2_.PFPKG_RELEASE asc
The result set in Oracle is NOT empty and shows me the expected data but the problem is that I only get the properties of the first hibernate object CnePlatformEdition with an empty set. The data fetched by the JOIN will not be stored into the Set (HashSet). The Set is 'null'.
Why the fetched values won't be stored into the Set ?
Thanks for any help.
With friendly regards
Detlef Bischke
Hibernate version:
3.2
Mapping documents:
CnePlatformEdition:
============
<hibernate-mapping>
<class name="com.ubs.usf.hibernate.beans.elvis.CnePlatformEdition"
table="CNE_T_PF_EDITIONS"
schema="CNE_ADM">
<id name="platformEditionId" type="long">
<column name="PF_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="platformName" type="string">
<column name="PF_NAME" length="100" not-null="true" />
</property>
<property name="platformRelease" type="string">
<column name="PF_RELEASE" length="100" not-null="true" />
</property>
<property name="lockStatus" type="string">
<column name="PF_STATUS" length="10" not-null="true" />
</property>
<set name="platformComponents" cascade="save-update, delete"
inverse="true" fetch="join">
<key><column name="PF_ID" precision="22" scale="0" not-null="true"/></key>
<one-to-many class="com.ubs.usf.hibernate.beans.elvis.CnePlatformComponent"/>
</set>
</class>
</hibernate-mapping>
CnePlatformComponent:
===============
<hibernate-mapping>
<class name="com.ubs.usf.hibernate.beans.elvis.CnePlatformComponent"
table="CNE_T_PF_COMPONENTS"
schema="CNE_ADM">
<id name="platformComponentId" type="long">
<column name="PFCOMP_ID" precision="22" scale="0" />
<generator class="sequence" />
</id>
<property name="platformEditionId" type="long">
<column name="PF_ID" length="20" not-null="true" />
</property>
<property name="platformComponentType" type="string">
<column name="PFCOMP_TYPE" length="20" not-null="true" />
</property>
<property name="sequenceNumber" type="long">
<column name="PFCOMP_SEQNO" precision="22" scale="0" not-null="true" />
</property>
<many-to-one name="cnePlatformPackage"
class="com.ubs.usf.hibernate.beans.elvis.CnePlatformPackage">
<column name="PFPKG_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
<property name="remark" type="string">
<column name="PFCOMP_REMARK" />
</property>
</class>
</hibernate-mapping>
CnePlatformPackage:
==============
<hibernate-mapping>
<class name="com.ubs.usf.hibernate.beans.elvis.CnePlatformPackage"
table="CNE_T_PF_PACKAGES"
schema="CNE_ADM">
<id name="packageId" type="long">
<column name="PFPKG_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="packageName" type="string">
<column name="PFPKG_NAME" length="100" not-null="true" />
</property>
<property name="packageRelease" type="string">
<column name="PFPKG_RELEASE" length="100" not-null="true" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
unimpotant for this case
Full stack trace of any exception that occurs:
unimpotant for this case
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
see above
Debug level Hibernate log excerpt:
unknown
Problems with Session and transaction handling?
No
Read this:
http://hibernate.org/42.html