2 Replies Latest reply on Mar 21, 2009 8:11 AM by Pawel Kaczor

    Multiple EntityHomes - One transaction

    Monkey Den Master

      I have an EntityHome subclass (UserHome) which acts as the controller for my use case.  In the persist/update method I am making use of several other EntityHome subclasses (RoleHome, AddressHome, etc).  I need all of the persist/update actions to collectively succeed or fail.  I see that EntityHome.joinTransaction() is protected so my idea is to call Home.getEntityManager().joinTransaction() on each.  I'm wondering if this is a viable option and whether it's functionally the same as calling EntityHome.joinTransaction() on each Home object?  Or, if there is a better method to wrap them in a single transaction.


        • 1. Re: Multiple EntityHomes - One transaction
          Monkey Den Master

          Anyone? To clarify and simplify, I have two distinct persistence contexts (2 schemas) which I need to pull into the current/same transaction to ensure that they are all updated or they all fail.  When I call persist on the first update and the second one fails, the first is not rolled back. 

          I've seen a reference to something similar in the old Seam forum, but it involved two EntityHomes using the same persistence context.  I have also added:

          <begin-conversation join="true" flush-mode="manual"/>

          to the xyz.page.xml file but it looks like EntityHome.persist() is explicitly calling flush() anyway.


          • 2. Re: Multiple EntityHomes - One transaction
            Pawel Kaczor Newbie

            Make sure your application server supports distributed transactions and is configured properly.