Thanks for your replay.
Given below is my mapping file class,
<class name="icp.entity.TannualStmtLine" table="TANNUAL_STMT_LINE">
<id column="ANNUAL_STMT_LN_ID" name="annualStmtLnId" type="string">
<generator class="assigned"/>
</id>
<property name="annualStmtLnNm" type="string">
<column length="30" name="ANNUAL_STMT_LN_NM" not-null="true"/>
</property>
<property name="updateTs" type="timestamp">
<column length="45" name="UPDATE_TS" not-null="true"/>
</property>
<property name="updUserId" type="string">
<column length="8" name="UPD_USER_ID" not-null="true"/>
</property>
<property name="exceptionIn" type="char">
<column length="1" name="EXCEPTION_IN" not-null="true"/>
</property>
<property name="ovAnnlStmtLnId" type="string">
<column length="3" name="OV_ANNL_STMT_LN_ID" not-null="true"/>
</property>
<set name="treserveFactors" table="TRESERVE_FACTOR">
<key column="ANNUAL_STMT_LN_ID"/>
<composite-element class="icp.entity.TreserveFactor">
<parent name="icp.entity.TannualStmtLine"/>
<property name ="treserveFactorPK" column="MEASURE_ID"/>
<property name ="treserveFactorPK" column="YEAR_NO"/>
<property name ="treserveFactorPK" column="QUARTER_NO"/>
<property name ="treserveFactorPK" column="POOL_CD"/>
<property name ="treserveFactorPK" column="COMPANY_NO"/>
<property name ="crntResrvFctrPc" column="CRNT_RESRV_FCTR_PC"/>
<property name ="min1ResrvFctrPc" column="MIN1_RESRV_FCTR_PC"/>
<property name ="min2ResrvFctrPc" column="MIN2_RESRV_FCTR_PC"/>
<property name ="min3ResrvFctrPc" column="MIN3_RESRV_FCTR_PC"/>
<property name ="min4ResrvFctrPc" column="MIN4_RESRV_FCTR_PC"/>
<property name ="updateTs" column="UPDATE_TS"/>
<property name ="updUserId" column="UPD_USER_ID"/>
<property name ="min5ResrvFctrPc" column="MIN5_RESRV_FCTR_PC"/>
</composite-element>
</set>
</class>
I am trying to add a collection of TRESERVE_FACTOR table in the TannualStmtLine
java class.
I use the below query to get the data from the database,
<sql-query name="findReserveFactors"><![CDATA[
SELECT TannualStmtLine.*,TreserveFactor.*
FROM REPORTER.TANNUAL_STMT_LINE TannualStmtLine
right outer join REPORTER.TRESERVE_FACTOR TreserveFactor
on TannualStmtLine.ANNUAL_STMT_LN_ID = TreserveFactor.ANNUAL_STMT_LN_ID
AND TreserveFactor.YEAR_NO=:year
AND TreserveFactor.QUARTER_NO=:quarter
AND TreserveFactor.MEASURE_ID=:measureid
AND TreserveFactor.COMPANY_NO=:comp
where
TannualStmtLine.ANNUAL_STMT_LN_ID ><> '310'
order by TannualStmtLine.ANNUAL_STMT_LN_ID]]>
<return alias ="TannualStmtLine" class="icp.entity.TannualStmtLine"/>
</sql-query>
I am completely missing something here. But, I don't what is it.
Below is the set,
<set name="treserveFactors" table="TRESERVE_FACTOR">
<key column="ANNUAL_STMT_LN_ID"/>
<composite-element class="icp.entity.TreserveFactor">
<parent name="icp.entity.TannualStmtLine"/>
<property name ="treserveFactorPK" column="MEASURE_ID"/>
<property name ="treserveFactorPK" column="YEAR_NO"/>
<property name ="treserveFactorPK" column="QUARTER_NO"/>
<property name ="treserveFactorPK" column="POOL_CD"/>
<property name ="treserveFactorPK" column="COMPANY_NO"/>
<property name ="crntResrvFctrPc" column="CRNT_RESRV_FCTR_PC"/>
<property name ="min1ResrvFctrPc" column="MIN1_RESRV_FCTR_PC"/>
<property name ="min2ResrvFctrPc" column="MIN2_RESRV_FCTR_PC"/>
<property name ="min3ResrvFctrPc" column="MIN3_RESRV_FCTR_PC"/>
<property name ="min4ResrvFctrPc" column="MIN4_RESRV_FCTR_PC"/>
<property name ="updateTs" column="UPDATE_TS"/>
<property name ="updUserId" column="UPD_USER_ID"/>
<property name ="min5ResrvFctrPc" column="MIN5_RESRV_FCTR_PC"/>
</composite-element>
</set>
I have given the parent tag in the set because ANNUAL_STMT_LN_ID column is a primary key on the table TANNUAL_STMT_LINE. I am trying to do the mapping for the remaining columns of the table TRESERVE_FACTOR.
TRESERVE_FACTOR table has the following primay keys,
<property name ="treserveFactorPK" column="MEASURE_ID"/>
<property name ="treserveFactorPK" column="YEAR_NO"/>
<property name ="treserveFactorPK" column="QUARTER_NO"/>
<property name ="treserveFactorPK" column="POOL_CD"/>
<property name ="treserveFactorPK" column="COMPANY_NO"/>
I have given the name of the property as treserveFactorPK. The reason is when I created a entitiy POJO for TRESERVE_FACTOR, it created two java classes.
TreserveFactorPK - Contains only all the primay keys of table TRESERVE_FACTOR.
TreserveFactor - Contains TreserveFactorPK as one of the element and all non-primay keys of TRESERVE_FACTOR.
My problem is how to define the property element within Composite-element. Say for example how to define the MEASURE_ID field, I have tried the below options, all are failed,
<property name ="measureId" column="MEASURE_ID"/>
<property name ="treserveFactorPK" column="MEASURE_ID"/>
<property name ="treserveFactorPK.measureId" column="MEASURE_ID"/>
error:
MeasureId not defined in class TreserveFactor
Can anyone tell me how to define this? Sorry, I know it may be insane to you.. But, I struck on this by more than two weeks now..........help is appericated..