Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.ny.estat.metadata.model" catalog="DTXRQ003">
<!-- catalog="DTXRQ003" -->
<class name="SeriesDefinition" table="XRV_SER_DFN_CTL" lazy="false">
<composite-id name="seriesDefinitionIdentity" class="org.ny.estat.metadata.model.SeriesDefinitionIdentity">
<key-property name="seriesName" column="ser_id_r" />
<key-property name="effectiveDate" column="efct_d" type="org.ny.estat.om.persist.hibernate.types.SimpleDateType"/>
<key-property name="districtCode" column="dist_c" />
</composite-id>
<bag name="items" lazy="false" table="XRV_SER_DFN_ITMS">
<key not-null="false">
<column name="ser_id_r"></column>
<column name="efct_d"></column>
<column name="dist_c"></column>
</key>
<one-to-many class="ItemDefinition"></one-to-many>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.ny.estat.metadata.model" catalog="DTXRQ003">
<class name="ItemDefinition" table="XRV_SER_DFN_ITMS" >
<composite-id name="itemDefinitionIdentity" class="org.ny.estat.metadata.model.ItemDefinitionIdentity">
<key-property name="seriesName" column="ser_id_r" />
<key-property name="effectiveDate" column="efct_d" type="org.ny.estat.om.persist.hibernate.types.SimpleDateType"/>
<key-property name="districtCode" column="dist_c" />
<key-property name="itemCode" column="itm_id_c" />
</composite-id>
<property name="itemDescription" column="ITM_DESC_X" />
<property name="itemType" column="ITM_TYP_C" />
<property name="mdrm4Code" column="MDRM_C" />
<!-- <property name="itemSequence" formula="((MAX(MIC_CTL_SEQ_R) -1) * 220) + MAX(MIC_ITM_SEQ_R) - MAX(ITM_OCRN_R) + 1" />
<property name="occurrenceCount" formula="MAX(ITM_OCRN_R)" /> -->
<!-- <many-to-one name="seriesDefinition" update="false" insert="false">
<column name="ser_id_r" ></column>
<column name="efct_d"></column>
<column name="dist_c"></column>
</many-to-one> -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
select
seriesdefi0_.ser_id_r as ser1_0_0_,
seriesdefi0_.efct_d as efct2_0_0_,
seriesdefi0_.dist_c as dist3_0_0_
from
DTXRQ003.XRV_SER_DFN_CTL seriesdefi0_
where
seriesdefi0_.ser_id_r=?
and seriesdefi0_.efct_d=?
and seriesdefi0_.dist_c=?
Hibernate:
select
items0_.ser_id_r as ser1_1_,
items0_.efct_d as efct2_1_,
items0_.dist_c as dist3_1_,
items0_.itm_id_c as itm4_1_,
items0_.ser_id_r as ser1_1_0_,
items0_.efct_d as efct2_1_0_,
items0_.dist_c as dist3_1_0_,
items0_.itm_id_c as itm4_1_0_,
items0_.ITM_DESC_X as ITM5_1_0_,
items0_.ITM_TYP_C as ITM6_1_0_,
items0_.MDRM_C as MDRM7_1_0_
from
DTXRQ003.XRV_SER_DFN_ITMS items0_
where
items0_.ser_id_r=?
and items0_.efct_d=?
and items0_.dist_c=?
Now the problem is that the second query fetches 181 rows. Tested it from the db. Also if I put a system out in the default construtor of ItemDefinition objects constructs it spits the out.println 181 times.
But the object in the SeriesDefinition of type items is empty. Have no clue how to procesd.
Thanx in advnace.