From: Guy B. (JIRA) <no...@at...> - 2006-05-08 15:20:26
|
Cloning an object with lazy initialization ------------------------------------------ Key: HHH-1726 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1726 Project: Hibernate3 Type: Bug Components: core Versions: 3.1.1 Reporter: Guy Bashan 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 ??? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |