4 Replies Latest reply on Jul 16, 2009 7:16 PM by Jean Luc

    Handling a transaction rollback

    Robert Raksi Newbie

      Hi!


      The problem is the following:
      - I start a conversation
      - create/modify some entities (usually through EntityHome beans) and then persist it
      - get some error from the database, the transaction gets rolled back


      How should I handle this situation? I display the error message on the client but when the user clicks the save button again, I get some errors 'like entity not managed', 'detached entity passed to persist'.


      Do I have to call something like this?


      home.setInstance(entityManager.merge(home.getInstance()))



      Or/and perhaps set the new entity's ID back to 0 if the operation was a persist?
      And what should I do with the entity's collections?