2 Replies Latest reply on Mar 18, 2010 9:48 AM by blabno

    Saving a persistent entity as a copy into the db

    James Domagalski Newbie

      Hey Guys,


      This might be a question more suited for hibernate forums, but I thought I would ask here first because everyone has been very helpful here in the past.


      I have an entity named Question that has a one to many relationship with Choice, which are entities as well.  What I would like to do is provide functionality that, when the Question is opened in its EnityHome, allows a user to click on a button that says, Save Question As New, that takes the current values in the Question, and the values within all of the Choices within the Question, and saves them all as new entities within the db. Basically Cloning or Copying Question object in a sense.


      All I was wondering if there would be some easy way to do this in Seam? Maybe detaching the Question entity and saving persisting that?


      My first thought was I could create a new question object,manually copy all the values from the Question, as well as all of the choice objects, and persist that new object to the db. But I figured there might be an easier way of doing so.


      Any information would be helpful.


      Thanks!