-->
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.  [ 8 posts ] 
Author Message
 Post subject: please explain detached objects, cloning issues
PostPosted: Mon Jul 12, 2004 3:41 pm 
Beginner
Beginner

Joined: Sun Jun 06, 2004 10:13 am
Posts: 20
we are finding that we need implement the clone method on our objects that are persisted because hiberante keeps some kind of magic connection to the actual object reference. we want to be able to rid a given object instance of ANY reference to hiberante, so we can just blank out the id's and resave it, and it will save as a new object. our current solution is to implement the clone() method on all our persistant objects.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 5:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If your object does not contain collection, simply session.evict(object) will be enough, no need to override the clone method.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 8:35 pm 
Beginner
Beginner

Joined: Sun Jun 06, 2004 10:13 am
Posts: 20
ok, thats a start. suppose it does contain a colllection (which it does, several infact).. do i traverse the object tree and call evict on all child object lists?

thanks
G


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 16, 2004 9:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Because of the dettach and lazy collection capability, Hibernate set its own impelmentation of collection, so I guess you'll have to copy it manually if you need to be "clean" as you said. But unless you have a remote client and obsolutly don't want the hibernate jar on the client side, I've never found a good reason to clone.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 2:40 pm 
Beginner
Beginner

Joined: Tue Jun 22, 2004 3:16 pm
Posts: 35
Emmanuel:

It seems Gavin thinks collection item can be evicted by cacade=all.

http://forum.hibernate.org/viewtopic.ph ... ct+cascade

Is that true?

Thanks,

J


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 2:43 pm 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
It is in my experience.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 4:26 pm 
Beginner
Beginner

Joined: Tue Jun 22, 2004 3:16 pm
Posts: 35
Really? Please take a quick look at this thread. Do I miss anything? Can you post your sample code and mapping file?

http://forum.hibernate.org/viewtopic.ph ... collection

Thanks,

J


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 7:54 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 8:38 am
Posts: 37
gjlloyd wrote:
ok, thats a start. suppose it does contain a colllection (which it does, several infact).. do i traverse the object tree and call evict on all child object lists?

thanks
G


You may want to check out beanlib for arbitrary cloning of the Hibernate entity object graph:
http://hansonchar.blogspot.com/2005/06/ ... rnate.html


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