• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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.
 
Something must be done about this. Let's start by reading this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic