-->
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.  [ 3 posts ] 
Author Message
 Post subject: Get
PostPosted: Mon Jul 02, 2007 9:11 am 
Newbie

Joined: Thu Mar 29, 2007 9:39 am
Posts: 10
hello,

In my code, i do 2 time session.get(of T)(id).
The second time, it seem nhibernate don't create a new object from the database, as the reference are the same.

I want 2 separate object, how can i force nhibernate to get the second from the database ?

Thanks
Decco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 1:43 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
I don't think it's possible. You can either use two sessions (if you must actually load the object from DB twice) or clone (if you just need two copies of the same thing). If the latter, cloning will be far more efficient.

Cloning can be accomplished by implementing ICloneable or using serialization (a la this post).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 5:08 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
I think that if you evict the first one and do another get you'll get another object. Mind you, any changes made to the evicted object will no longer be tracked...

Symon.


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