it seems to be an internal exception of Cloner… all my objects are Serializable… and I can do a deepClone with org.hibernate.util.SerializationHelper.
Another question:
You wrote "It is useful if you need to deattach an entity from an EntityManager."
So, all my objects are not detached and all are having ids (from hibernate). So, I need to have a deepClone with all id's resetted to null, so that I can persist the whole object graph again as a copy. Did you mean this with your statement?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you need to clone a object graph use deepClone(Object bean, Class<?> clazz). It will clone all and deattach it from an EntityManager. Deattach an object won't clear its ids, it will just fetch all lazy data and eliminating any problem with lazy fetch. But be careful it can down your performance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The deepCloneSerialized perform a deep clone but it doesn't deattach because it is like a picture of the original object. some things may contain data that are lost in this process. There are two methods available for cloning objects, choose one that best fits your needs
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Welcome to Open Discussion
Hi, thank you for the library.
But I get errors by deepCloneSerialization:
org.cloner.CloneException: java.io.StreamCorruptedException: invalid stream header
it seems to be an internal exception of Cloner… all my objects are Serializable… and I can do a deepClone with org.hibernate.util.SerializationHelper.
Another question:
You wrote "It is useful if you need to deattach an entity from an EntityManager."
So, all my objects are not detached and all are having ids (from hibernate). So, I need to have a deepClone with all id's resetted to null, so that I can persist the whole object graph again as a copy. Did you mean this with your statement?
If you need to clone a object graph use deepClone(Object bean, Class<?> clazz). It will clone all and deattach it from an EntityManager. Deattach an object won't clear its ids, it will just fetch all lazy data and eliminating any problem with lazy fetch. But be careful it can down your performance.
The deepCloneSerialized perform a deep clone but it doesn't deattach because it is like a picture of the original object. some things may contain data that are lost in this process. There are two methods available for cloning objects, choose one that best fits your needs