Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

EntityBean Transcation inside UserTranscation

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[ July 10, 2008: Message edited by: jigara shah ]
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic