• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How do I setRollBackOnly on a sessionBean using CMT and JTA

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to J2EE v5 and I am trying to understand how CMT and JTA work

I want to rollback a transaction in Stateless SessionBean and all the documentation I have read is that I should use setRollBack on the EJBContext.

I have created a testcase where I increment a number in the DB, call the persist on the EntityManager and then try to roll it back using em.getTransaction().setRollbackOnly(); . When I do this I get returned an error


I used netbeans 6.5 to create the sessionbean and the corresponding enity

Below is my session bean



I would appreciate if someone could put me on the right track and even post an example session bean that I could use as a template.

Thanks
 
Jag Bains
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found out how

Needed to add :

@Resource
protected SessionContext ctx;

Then to rollback

ctx.setRollBackOnly();

Works a treat.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic