-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate update with orphan problem
PostPosted: Mon Mar 28, 2011 7:54 am 
Newbie

Joined: Mon Mar 28, 2011 7:38 am
Posts: 1
I have a parent object and it has childs.In my database I have one record belong that parent and 3 child record associated with that parent.When I attempt to update childs , that doesn't.And I realized these records is added to table.
MY Parent hbm
Code:
<hibernate-mapping>
    <class name="parent" table="Parent">
        <id name="id" type="java.lang.Long">
            <column name="ID" precision="16" scale="0" />
            <generator class="sequence">
                <param name="sequence">SEQ_Parent</param>
            </generator>
        </id>
        <property name="cycleCode" type="string">
            <column name="CYCLE_CODE" length="10" />
        </property>
         <set name="cycles" inverse="true" lazy="false" cascade="all" table="CHILD">
           <key column="CYCLE_CODE" property-ref="cycleCode" />
           <one-to-many class="Child"/>
        </set>
    </class>   
</hibernate-mapping>

<hibernate-mapping>
    <class name="child" table="CHILD">
        <id name="id" type="java.lang.Long">
            <column name="ID" precision="16" scale="0" />
            <generator class="sequence">
                <param name="sequence">SEQ_CHILD</param>
            </generator>
        </id>
       
         <many-to-one name="cycle" class="parent" column="CYCLE_CODE" property-ref="cycleCode" />
     
    </class>   
</hibernate-mapping>




parent p=session.load(1,parent.class);
p.setCycles(Arrays.asList(3,4,5,6);
session.saveorupdate(p);





if my parent has 1,2 as child befor update, after 3,4,5,6 values appears with then in database, I want them to be dropped


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

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.