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.  [ 4 posts ] 
Author Message
 Post subject: How to update collection entities via saveOrUpdateCopy
PostPosted: Sun Feb 27, 2005 10:07 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
Class Person has list of Class House instances

and X has a business key, where as y has "sequence" id.

Suppose in one session, I save Person p
calling saveOrUpdateCopy(p) with saving person's homes with cascade=all

Then in another session, I created new Person instance with same identifier and with a new list of houses.
Then I call saveOrUpdateCopy(p), it correctly calls update for person (Since id's are same) and it inserst the houses to the House table.

I wonder that how can I delete the previous houses list?
I mean how can I map such a logic via hibernate:

If a owner of collection is updated with saveOrUpdateCopy, get List of collection entities from database, "DELETE ALL" and insert new entites? How to update collection entities via saveOrUpdateCopy????

_________________
-developer


Top
 Profile  
 
 Post subject: Delete old Listentries at update?
PostPosted: Mon Mar 07, 2005 5:44 am 
Newbie

Joined: Mon Mar 07, 2005 5:29 am
Posts: 8
I have an Object ParamX which stores 2 Lists.
I can fill te list using Methodes in ParamX, when i call create the 2 Lists were stored in separate tables => All OK!
But when i modify the lists (clear and add new entries) of the ParamX-Object and call the update-Methode the new entries don't override the old entries.

The old entries still appear plus the new!

What must i do to remove the previous listentries if they are not any longer in the list when i call update??

Code:
<!DOCTYPE hibernate-mapping SYSTEM
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="packagexy....">
   
   <class name="ParamX" table="paramx" >

      <id name="id" column="uid" type="long">
         <generator class="assigned"/>
      </id>

      <property name="date">
         <column name="date"/>
      </property>
      <property name="time">
         <column name="time"/>
      </property>
      <property name="user">
         <column name="user"/>
      </property>

      <list name ="listA" table="listA">
         <key column="uid" />
         <index column="posn" />
         <composite-element class="InfoDataA">
            <property name="name" type="string" />
            <property name="gv" type="string" />
            <property name="gvArt" type="string" />
         </composite-element>
      </list>

      <list name ="listB" table="listB">
         <key column="uid" />
         <index column="posn" />
         <composite-element class="InfoDataB">
            <property name="name" type="string" />
            <property name="gv" type="string" />
         </composite-element>
      </list>
   </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: Found my problem!
PostPosted: Mon Mar 07, 2005 10:58 am 
Newbie

Joined: Mon Mar 07, 2005 5:29 am
Posts: 8
I had an error in my Java implementation where i clear and update my list!

Now it runs fine!


Top
 Profile  
 
 Post subject: So what?
PostPosted: Thu Mar 10, 2005 6:01 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
Sorry, but I can say that we are not talking about the same thing.

Your case is the simple saveOrUpdate scenario for collections.

_________________
-developer


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.