• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Can I use UserTransaction within a CMP Session bean?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically the problem is as follow:
I have the following method in a Statefull session bean:
public Whatever do()
{
processSomething();
notify();
}
the notify() basically notifying the client that then query for the something that was processed in the processSomething() method.
THE PROBLEM is that the changes have not been committed yet as the do() method is not finished yet and the container has not committed the changes.
THE QUESTION is - can I use UserTransaction inside
processSomething to commit the changes and leave the bean as CMP? I want to leave it as CMP as there are more methods on the bean and I don't want to have to manage the transactions for them.
Anyone has any other ideas?
Thanks in advanced.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can either set transaction attributes for methods you want in deployment descriptor or you can use javax.transaction.usertransaction and put transaction boundaries across methods you want
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An EJB must either be CMT or BMT, it can not be both. Therefore, if you would like some methods in a Session Bean to be CMT and others to be BMT, then you should break your single Session Bean into two separate Session Beans.
Trying to access the UserTransaction in a CMT bean will cause a IllegalStateException exception.
 
Get me the mayor's office! I need to tell him about this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic