-->
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: Cloning an object with lazy initialization
PostPosted: Mon May 08, 2006 11:35 am 
Newbie

Joined: Tue Dec 06, 2005 10:13 am
Posts: 17
I know this problem probably in not concerned directly wil Hibernate, but it is still a weird problem:
I wrote a method for making a deep copy on some object that holds a lot of objects under it. I make the deep copy by simply looping all objects, cloning them and setting ids to null. It used to work great, untill I did the following thing:
(It can be best demonstrated with an example)
Suppose I have two objects A and B with One to Many relation (Meaning I have: "A.Bs" where "Bs" is a Set/List), I added also B entity as a member of A: For exmaple: "A.defaultB" where "defaultB" holds a single default value of B.
Now, this causes an exception when using BeanUtils.clone, making it impossible to clone the object:
06/05/08 19:05:29 java.lang.NoSuchMethodException: Property 'callback' has no getter method
06/05/08 19:05:29 at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java)
06/05/08 19:05:29 at org.apache.commons.beanutils.PropertyUtils.copyProperties(PropertyUtils.java:318)

I assume the lazy initialization mechanism adds a member that cannot be copied to the newly created object.

Is it possible that the lazy initialization mechanism makes it impossible to clone objects ???


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.