-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Please help....Hibernate Composite id mapping.
PostPosted: Thu Sep 25, 2008 12:39 pm 
Newbie

Joined: Wed Sep 24, 2008 8:12 pm
Posts: 3
I have a table in database which has following mapping it does not work:


Code:
---------------------------contact-phone.hbm.xml---------------------
<class name="ContactPhone" table="SPP_AGG_CONTACT_PHONE">
    <composite-id>
        <key-property name="phoneNumber" column="PHONE_NUMBER" type="string"/>
        <key-many-to-one name="contact" column="CONTACT_ID" class="ContactInfo" lazy="false"/>
        <key-property name="typeId" column="TYPE_ID" type="integer"/>
    </composite-id>
    <property name="index" column="ORDER_NUMBER" type="integer"/>   
</class>

---------------------------contact.hbm.xml---------------------------
<class name="ContactInfo" table="SPP_AGGREGATOR_CONTACT">
   <id name="id" column="CONTACT_ID" unsaved-value="-1" type="long">
      <generator class="sequence">
         <param name="sequence">SPP_AGG_CONTACT_ID_SEQ</param>
      </generator>
   </id>
   <property name="firstName" column="FIRST_NAME"/>
   <property name="lastName" column="LAST_NAME"/>
   <property name="createUser" column="CREATE_USER" update="false"/>
   <property name="createDate" column="CREATE_DATE" type="calendar_date" update="false"/>
   <property name="updateUser" column="UPDATE_USER"/>
   <property name="updateDate" column="UPDATE_DATE" type="calendar_date"/>
   <many-to-one name="aggregator" class="Aggregator" column="AGGREGATOR_ID" lazy="false" insert="false" update="false"/>      
   <list name="emailAddress" table="SPP_AGG_CONTACT_EMAIL_ADDR" cascade="all">
      <key column="CONTACT_ID"/>
      <list-index column="ORDER_NUMBER"/>
      <element column="EMAIL_ADDRESS" type="string"/>
   </list>
   <list name="phoneNumber" table="SPP_AGG_CONTACT_PHONE" cascade="all">
      <key column="CONTACT_ID" not-null="true"/>
      <list-index column="ORDER_NUMBER"/>
      <one-to-many class="ContactPhone"/>
   </list>
    <set name="notes" table="SPP_CONTACT_NOTES" cascade="save-update" lazy="false" inverse="false" sort="unsorted">
      <key column="CONTACT_ID"/>
      <many-to-many column="NOTE_ID" class="NoteData"/>
    </set>
</class>



I get org.hibernate.MappingException: Repeated column in mapping for entity: com.pge.csis.dr.thirdparty.aggregation.beans.ContactPhone column: CONTACT_ID (should be mapped with insert="false" update="false").

Please advise.....

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2008 4:23 am 
Newbie

Joined: Wed Sep 24, 2008 11:34 am
Posts: 3
HI,
I think that you should insert at the end of your file contact-phone.hbm.xml
the following:

<many-to-one name="contact" class="ContactInfo" fetch="join" >
<column name="CONTACT_ID" />
</many-to-one>

and then update your class with the many-to-one object.
bye.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.