• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

In a Roll back EJB exception is thrown

 
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using JPA with hibernate in a stateless session been and and that bean is called from a servlet. I am using CMP and when ever a roll back occurs it is thrown back to the servlet as a EJBException. My problem is, since EJBException is thrown for other reasons as well, how to figure out whether it was thrown for a roll back or some other reason. At the same time, can't we catch the Transaction aborted exception in the EJB. I tried using RuntimeException in the catch clause, but it didn't work. Anticipating a reply. Thanks.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am using CMP and when ever a roll back occurs it is thrown back to the servlet as a EJBException


That's the wrong way roung, isn't is? The EJBException causes a transaction to be rolled back, not a rollback causing an EJBException? Or am I misunderstanding you?


since EJBException is thrown for other reasons as well, how to figure out whether it was thrown for a roll back or some other reason


What other reason causes it to be thrown?
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks for the reply. Yes good point, EJBException is thrown and then roll back happens. That's the way it should be. But the problem I am having is, when I try to add a record with the same primary key, I get this problem. I really don't know what to do, meaning, what exception which I need to capture. I am using JPA with hibernate.

Thanks and expecting a reply soon.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic