Is there an easy to way to save a cloned object and its relationships as if they were transient? The two approaches we've tried have their problems.
The first is to have a method on our Entity interface which resets the ID to null and then calls the same method on any children. This is tideous to implement and error prone.
The second is to use reflection, writing a recursive method that looks for Entity relationships using reflection which also sets the IDs to null. This seems possible but we have to be careful about circular references.
So my question is...is there an easier way?
Also, do the proxies embedded in the Entities coming back from Hibernate contain state which could cause problems when saving clones back to the database?
Thanks.
Ashley
|