• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EntityBean Transcation inside UserTranscation

 
jigara shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jigara shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ July 10, 2008: Message edited by: jigara shah ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic