Topic
  • 3 replies
  • Latest Post - ‏2012-09-10T18:17:11Z by manishpoddar
manishpoddar
manishpoddar
5 Posts

Pinned topic How to mark setRollBackOnly in case of OpenJPA CMT on WAS 7

‏2012-09-07T03:25:05Z |
I want to mark CMT for rollback in case of business exception.
Since we are not using EJB, sessionContext is not available to me.
Not sure how I could mark setRollBackOnly.
Tried enitityManager.getTranaction().setRollBackOnly().
But that's not working. Seems that I could not use EntityTransaction in case of CMT.
Updated on 2012-09-10T18:17:11Z at 2012-09-10T18:17:11Z by manishpoddar
  • leealber
    leealber
    19 Posts

    Re: How to mark setRollBackOnly in case of OpenJPA CMT on WAS 7

    ‏2012-09-07T15:56:42Z  
    I am curious how is your application take part in a CMT? Can you provide more details on this aspect?

    • Assuming it is a JEE application,
    • As mentioned, you are not using EJB; what type of component are you using? servlet, JSP ?
    • What is the application call path looks like and how is the application interact with JPA?

    Albert Lee.
  • manishpoddar
    manishpoddar
    5 Posts

    Re: How to mark setRollBackOnly in case of OpenJPA CMT on WAS 7

    ‏2012-09-07T17:29:50Z  
    We are using WESB, Mediation will invoke DAO (plain java). In DAO we are using entityManager.joinTransaction().
    We had implemented transaction management at services (web services) level. However want to mark transaction for rollback in case of exception.
  • manishpoddar
    manishpoddar
    5 Posts

    Re: How to mark setRollBackOnly in case of OpenJPA CMT on WAS 7

    ‏2012-09-10T18:17:11Z  
    I had used following code to set rollbackonly for CMT and it work!

    final InitialContext initialContext = new InitialContext();
    final UOWSynchronizationRegistry uowSyncRegistry =
    (UOWSynchronizationRegistry)initialContext.lookup("java:comp/websphere/UOWSynchronizationRegistry");
    uowSyncRegistry.setRollbackOnly();