• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving Object Relationships dinamically

 
Carlos Conti
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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,
Carlos.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic