I need to be able to duplicate persisted instances. The problem is the id field everywhere. Therefore I would need a way to findout the relationships specified in the orm.xml for a specific class (not done through annotations) in order to recursively traverse the object tree and set id=null in the clone object.
For deep clone mechanism I am using serialization. Is there any pitfall on this approach?. I have read in many places it is not the most suitable to do, but can't figure out something simpler and quicker.
Thanks four your help,
posted 7 years ago
What ORM solution are you using?
In EclipseLink there is a copyObject() API that provides a depth option, and option to null out the Id.