4 Replies Latest reply on Dec 7, 2007 8:39 AM by Sheng Huang

    detached entity passed to persist

    Tobias Kilian Newbie

      Hello Folks!

      in the examples it looks all so easy, but i still dont get it right.

      What are the possible reasons for this exception to occur?
      javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist

      I dont call em.persist nor em.merge or anything. i just want to edit that @DataModelSelection annotated entity in a form and have it persisted.
      I saw at least two possible solutions to get the right object:
      @DataModelSelection
      Entity selectedEntity;

      in the booking example HotelBookingAction.java:

       @In(required=false) @Out
       private Hotel hotel;
      
      
       @Begin
       public void selectHotel(Hotel selectedHotel)
       {
       hotel = em.merge(selectedHotel);
       }
      


      however both of these option lead to the same error.

      So again: what are the reasons for the PersistentObjectException to occur?

      Thanks for any hints.
      Tobias Kilian

      PS: i know this is ejb stuff, so perhaps i should ask there?