3 Replies Latest reply on Mar 8, 2004 9:18 AM by gustad20

    Urgent help with Transations

    gustad20

      I am using JBoss server. And Sybase 12.5 Database.
      Here is my scenario :
      Say i have three entities : City , Inhabitant and Addresses

      If i delete a City , i have to delete all its Inhabitant and the Inhabitant's Addresses. (One Inhabitant can have multiple Addresses).
      Its also possible to delete just the Inhabitant and hence we have to delete his Addresses.....also we can just delete just the Address.

      Now of all these Entities , Addresses is not dependent on any other Entitiy....so it wouldnt start its own transaction. But City and Inhabitant both would need to start a new UserTransaction. But the problem is.....how do i know from within Inhabitant, if i am being called from City's UserTransaction or i have to start my own UserTransaction.

      Hope i made it clear.....if you have ant better suggestions on how to implement this...do let me know .

        • 1. Re: Urgent help with Transations

          javax.transaction.UserTransaction.getStatus()

          Regards,
          Adrian

          • 2. Re: Urgent help with Transations
            gustad20

            Adrian,

            Thanx for the response.

            These are two different transactions !! Inside City...i do a lookup(UserTransaction) and then tx.begin(). Now this transaction calls Inhabitant....which also does a lookup(UserTransaction) and then tx.begin(). I get different UserTransaction objects each time....hence getStatus() doesnt help , if u ask why need to start a new UserTransaction...then my answer is that , its possible to delete just Inhabitant and doing that would require to succesfully delete all Adresses...hence the need for the transaction.

            Hope it helps

            • 3. Re: Urgent help with Transations
              gustad20

              Adrian,
              You were right. I tried it and it works