GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes Set- Key Mapping issue with nested-composite-element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Set- Key Mapping issue with nested-composite-element" Watch "Set- Key Mapping issue with nested-composite-element" New topic
Author

Set- Key Mapping issue with nested-composite-element

hariharakarthi Subramanian
Greenhorn

Joined: Aug 11, 2008
Posts: 11
Hi,

I trying to join two tables.

The table and its details are as follows,
TANNUAL_STMT_LINE --- A
TRESERVE_FACTOR -- B

Trying to add table B (TRESERVE_FACTOR) as collection in table A (TANNUAL_STMT_LINE)

The mapping file is given below,




Below is the code snippet used to execute the above query.





The sysout is as follows,

Code:
021
ALLIED LINES
Hibernate: select treservefa0_.ANNUAL_STMT_LN_ID as ANNUAL1_0_, treservefa0_.MEASURE_ID as MEASURE2_0_, treservefa0_.YEAR_NO as YEAR3_0_, treservefa0_.QUARTER_NO as QUARTER4_0_, treservefa0_.POOL_CD as POOL5_0_, treservefa0_.COMPANY_NO as COMPANY6_0_, treservefa0_.CRNT_RESRV_FCTR_PC as CRNT7_0_, treservefa0_.MIN1_RESRV_FCTR_PC as MIN8_0_, treservefa0_.MIN2_RESRV_FCTR_PC as MIN9_0_, treservefa0_.MIN3_RESRV_FCTR_PC as MIN10_0_, treservefa0_.MIN4_RESRV_FCTR_PC as MIN11_0_, treservefa0_.UPDATE_TS as UPDATE12_0_, treservefa0_.UPD_USER_ID as UPD13_0_, treservefa0_.MIN5_RESRV_FCTR_PC as MIN14_0_ from REPORTER.TRESERVE_FACTOR treservefa0_ where treservefa0_.ANNUAL_STMT_LN_ID=?
null
0742



I could not get the ANNUAL_STMT_LN_ID column in the set, which is key column. The mapping may look very complex. But, the mappings are mandatory for the project requirement.


I have two pojo classes for the table TRESERVE_FACTOR, class TreserveFactor and TreserveFactorPK. The class TreserveFactorPK contains properties for primary keys of TRESERVE_FACTOR table. Hence, I have to use the nested-composite-element to do the mapping.

Now, the quetion is I could not map the key of the set. The key ANNUAL_STMT_LN_ID is a primary key. Hence, it needs to be reference inside the nested-composite-element. But, when I tried it, hibernate throws error saying that duplicate mapping. I can't get rid of key from the set.

I need to refer the key ANNUAL_STMT_LN_ID to TreserveFactorPK inside the nested-composite-element. Is it possible? is there any other option ? Help is appericated
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
Hari, if you would put the codes under [code]-tag, the things will be more legible for all of us. It will bring you quick help. TIA


Programmer Analyst || J2EE web development/design
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set- Key Mapping issue with nested-composite-element