-->
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: Inserting parent/child both with composite key
PostPosted: Fri Apr 10, 2009 12:07 am 
Newbie

Joined: Tue Sep 27, 2005 5:48 am
Posts: 5
Hibernate version: 3.1
Name and version of the database you are using: Oracle 10g

Hi, I have composite primary key both in parent and child. Parent and child have one to many relationship. Upon inserting, parent record is successfully inserted but child is not getting inserted. Neither I see any exception. Following is my mapping:

Code:
<hibernate-mapping>

   <class name="ParentClass" table="Parent">
      
      <composite-id name="id" class="parentId">
         <key-property name="parentCol1"  type="long" column="parentCol1"/>
         <key-property name="parentCol2" type="String"  column="parentCol1"/>
      </composite-id>
      
      <property .....
   
      <list name="childrenList" inverse="true" lazy="true" cascade="save-update" table="Child">
         <key>
            <column name="childCol1"/>
            <column name="parentCol1"/>
            <column name="parentCol2"/>
         </key>
         <index>
            <column name="parentCol1"/>
            <column name="parentCol2"/>
         </index>
         <one-to-many class="ChildClass"/>
      </list>   

   </class>
</hibernate-mapping>


<hibernate-mapping>

   <class name="ChildClass" table="Child">
      
       <composite-id name="id" class="childId">
           <key-property name="childCol1" type="integer" column="childCol1" />
      <key-property name="parentCol1"  type="long" column="parentCol1"/>
      <key-property name="parentCol2" type="String"  column="parentCol1"/>
       </composite-id>

   <property .....

   <many-to-one name="parent" class="ParentClass" insert="false" update="false">
      <key>
         <column name="parentCol1"/>
         <column name="parentCol2"/>
      </key>
   </many-to-one>

   </class>
</hibernate-mapping>



Any help will be greatly appreciated.

Thanks.

_________________
Catch me if you Can


Top
 Profile  
 
 Post subject: Re: Inserting parent/child both with composite key
PostPosted: Fri Apr 10, 2009 12:51 am 
Newbie

Joined: Mon Feb 02, 2009 11:40 pm
Posts: 1
Location: Bangalore
overide equals() and hashcode() method , for compositid class
but this is not the solution


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.