This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes Need help with Transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Need help with Transactions " Watch "Need help with Transactions " New topic

Need help with Transactions

Pappu Kumar
Ranch Hand

Joined: Oct 01, 2002
Posts: 69
I am using Weblogic 7.0 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 it wouldnt start its own transaction. But City and Inhabitant both would need to start a new UserTransaction. But the problem 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 let me know .
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Hi Pappu,
Not sure if this is the answer you are looking for, but your entity bean implements the EntityBean interface. This interface contains the "setEntityContext()" method, which receives a parameter of type EntityContext. The super interface of "EntityContext" is EJBContext. This interface ("EJBContext") contains the "getUserTransaction()" method, which returns a UserTransaction. And the "UserTransaction" interface contains the "getStatus()" method -- which returns an integer that indicates the current transaction status (including whether there is no current transaction).
Hope this helps.
Good Luck,
[ March 09, 2004: Message edited by: Avi Abrami ]
Don't get me started about those stupid light bulbs.
subject: Need help with Transactions
Similar Threads
Factoring Out Address Information
DOA or not DAO this is the question?
General Questions on EJB
Listing all IP adresses on local network (LAN)