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 ???
|