0 Replies Latest reply on Jul 27, 2010 11:08 AM by bossdida

    Atomic Conversation

    bossdida

      Hi all,


      I'd like to implement an atomic conversation. My simplified app consists of 2 pages; AddPerson.xhtml and AddAddress.xhtml.


      App uses JPA and Hibernate db provider underneath  and I'm begining the conversation in savePerson() with flush mode to MANUAL, then persist person to PersonTbl(entityManager.persist(person)), proceed to AddAddress.xhtml.


      In saveAddress(), which end the conversation, persists address object then fluch content of entity manager.(entityManager.persist(address); entityManager.flush();)


      As it is seen I'm expecting the changes to person and address objects will be prooagated to db at the end of saveAddress() method (if completed sucessfuly) or transaction will be rolled back and none of then saved to db at all.


      However, it saves person to db at the end of savePerson() and even save address in saveAddress() when I throw an exception intentionaly. Entity manager flushes the content in every entityManager.presist(T) case.



      What am I doing wrong ?
      (I use @GeneratedValue attributed for person id and address id fileds, is it possible that this attribute cause to this behaviour ?)


      Thanks for any contribution.