Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Set- Key Mapping issue with nested-composite-element

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I trying to join two tables.

The table and its details are as follows,

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,

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=?

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
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic