wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes EntityBean Transcation inside UserTranscation    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EntityBean Transcation inside UserTranscation    " Watch "EntityBean Transcation inside UserTranscation    " New topic
Author

EntityBean Transcation inside UserTranscation

jigara shah
Greenhorn

Joined: Apr 20, 2007
Posts: 7
I have a method in java class which uses UserTransaction and within transaction it calls enitiy bean create() (It creates a row in database). Now just incase if i roll back this transaction then it does not rollback entity created in entity bean.

structure of the code is something like this....


Transaction attribute for entity bean is Required.

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

The transactional XML attributes only come into play if you are using Container Management Transactions (CMT). If you are creating/starting transactions on your own, or bean managed transaction (BMT), the behavior is completely up to you.


My Blog: Down Home Country Coding with Scott Selikoff
jigara shah
Greenhorn

Joined: Apr 20, 2007
Posts: 7
Originally posted by Scott Selikoff:
The transactional XML attributes only come into play if you are using Container Management Transactions (CMT). If you are creating/starting transactions on your own, or bean managed transaction (BMT), the behavior is completely up to you.


Yes i get that. But my question is, I am calling a method which has CMT inside a method (in a separate class) which is under Usertransaction. Then it should join User transaction right ?

In summary i am trying to figureout "Will calling EnitiyBean create() method which is under CMT; will join User transaction if its called from that transaction ?"


ClassA {
UT.begin
ejbCreate();
UT.end
}




//Under CMT
EntityBeanClassB {
ejbCreate();
}
[ July 10, 2008: Message edited by: jigara shah ]
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

It should join the transaction, although depending on your ejb version and server it may throw an exception. Why don't you try and see for yourself? Best way to learn is to try it out.
jigara shah
Greenhorn

Joined: Apr 20, 2007
Posts: 7
I tried but it does not join. so i am trying to figure out some test which can explain me why this has happened.
jigara shah
Greenhorn

Joined: Apr 20, 2007
Posts: 7

[ July 10, 2008: Message edited by: jigara shah ]
 
Don't get me started about those stupid light bulbs.
 
subject: EntityBean Transcation inside UserTranscation
 
Similar Threads
Question about "trans-attribute" in EJB 2.1
Question about transactions (CMT). Am I wrong in understanding "Transactions" at all?
Doubt in Transanction Attributes
Starting a client transaction
record updation in entity beans with attribute "never"?