3.0.1:
Mapping documents:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--Hibernate Table Definition-->
<class name="com.swissre.por.common.bo.PORTreaty" table="IUF31S.TTREATY">
<!--Primary Key Definition-->
<id column="ID" name="id" type="integer" unsaved-value="null">
<generator class="native"/>
</id>
<!--Properties Definition-->
<property column="FIRST_INCEP" insert="true" name="firstInceptionDate" not-null="true" type="date" unique="false" update="true"/>
<property column="MAIN_PARTNER_ID" insert="true" name="mainCedentId" not-null="true" type="integer" unique="false" update="true"/>
<property column="TREATY_NAME" insert="true" length="80" name="treatyName" not-null="false" type="string" unique="false" update="true"/>
<property column="TREATY_REF" insert="true" length="10" name="treatyRef" not-null="false" type="string" unique="false" update="true"/>
<property column="UPD_USER" insert="true" length="10" name="updateUser" not-null="true" type="string" unique="false" update="true"/>
<property column="UPD_TS" insert="true" name="updateTimestamp" not-null="true" type="timestamp" unique="false" update="true"/>
<property column="PUBID_TTY" insert="true" name="publicIdTreaty" not-null="false" type="integer" unique="true" update="true"/>
<property column="ACTIVE_YN" insert="true" name="active" not-null="true" type="boolean" unique="false" update="true"/>
<property column="NOTIONAL_YN" insert="true" name="notional" not-null="true" type="boolean" unique="false" update="true"/>
<!--Associations Definition-->
<many-to-one cascade="none" class="com.swissre.por.common.ref.PORTransactionType" column="TRNTYP" name="transactionTypeRelatedByTransactionTypeKey" unique="true"/>
<many-to-one cascade="none" class="com.swissre.por.common.ref.PORUSGaapType" column="USGAAPTYP" name="USGaapTypeRelatedByUsGaapClassificationTypeKey" unique="true"/>
<many-to-one cascade="none" class="com.swissre.por.common.ref.PORTreatyType" column="TREATY_TYPE" name="treatyTypeRelatedByTreatyTypeKey" unique="true"/>
<many-to-one cascade="none" class="com.swissre.por.common.ref.PORAgreementType" column="AGRTYP" name="agreementTypeRelatedByAgreementTypeKey" unique="true"/>
<many-to-one cascade="none" class="com.swissre.por.common.ref.PORBusinessStatus" column="BU_STATUS_HIGH" name="businessStatusRelatedByHighestBusinessStatusKey" unique="true"/>
<bag cascade="all-delete-orphan" inverse="true" lazy="true" name="treatyMainLobs">
<key column="TR_ID"/>
<one-to-many class="com.swissre.por.common.bo.PORTreatyMainLob"/>
</bag>
</class>
</hibernate-mapping>
Name and version of the database you are using:
DB2 V7
The generated SQL (show_sql=true):
[4/21/05 15:54:22:692 CEST] 5dc90afd SystemOut O Hibernate: select this_.ID as ID0_, this_.FIRST_INCEP as FIRST2_25_0_, this_.MAIN_PARTNER_ID as MAIN3_25_0_, this_.TREATY_NAME as TREATY4_25_0_, this_.TREATY_REF as TREATY5_25_0_, this_.UPD_USER as UPD6_25_0_, this_.UPD_TS as UPD7_25_0_, this_.PUBID_TTY as PUBID8_25_0_, this_.ACTIVE_YN as ACTIVE9_25_0_, this_.NOTIONAL_YN as NOTIONAL10_25_0_, this_.TRNTYP as TRNTYP25_0_, this_.USGAAPTYP as USGAA12_25_0_, this_.TREATY_TYPE as TREATY13_25_0_, this_.AGRTYP as AGRTYP25_0_, this_.BU_STATUS_HIGH as BU15_25_0_ from IUF31S.TTREATY this_ where this_.ID = ?
[4/21/05 15:54:22:801 CEST] 5dc90afd SystemOut O Hibernate: select treatymain0_.TR_ID as TR4___, treatymain0_.ID as ID__, treatymain0_.ID as ID0_, treatymain0_.HASINFORCE as HASINF2_123_0_, treatymain0_.UPD_TS as UPD3_123_0_, treatymain0_.TR_ID as TR4_123_0_, treatymain0_.MAINLOB as MAINLOB123_0_ from IUF31S.TTTYMAINLOB treatymain0_ where treatymain0_.TR_ID=?
Hi,
The following code retrieves the main lobs as well, however this collection is explicitly set as lazy:
public void getShallowTreatyById(Integer id) {
Session session = null;
try {
session = getSession();
Criteria c = session.createCriteria(PORTreaty.class);
PORTreaty treaty = (PORTreaty)c.add(Restrictions.idEq(id)).uniqueResult();
}
catch (HibernateException e) {
e.printStackTrace();
}
}
What I am doing wrong?
Thanks
Juerg
|