-->
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: Incorrect instance reference saved
PostPosted: Thu Jul 20, 2006 8:19 am 
Newbie

Joined: Thu Jul 20, 2006 6:11 am
Posts: 1
Hibernate version: 3.1

..beginTransaction();

MySmallObject localRef new MySmallObject(); // holds a collection
session.save(localRef);

MyOtherObject localRef2 = new MyOtherObject();
localRef2.setProperty(localRef)
session.save(localRef2);

// reusing the MySmallObject declaration above!!
localRef = new MySmallObject(); // holds another collection
session.save(localRef);

// reusing the OtherObject declaration above!!
localRef2 = new MyOtherObject();
localRef2.setProperty(localRef);
session.save(localRef2);

..commit();

The strange effect that happens:

All collectioins of localRef (for both instances) get saved correctly but: the first MyOtherObject that got saved to the db misteriousely has a reference to the last MySmallObject instead of the correct one.. (alway the last instance reference of localRef gets saved with the MyOtherObject references!!

This only happens if there are collections in the MySmallObject. Why is it not possible to reuse local declarations in such a szenario?

Comitting and reopening the transaction does not help.


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.