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

Is a PersistenceException per default a system exception?

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

Is a PersistenceException per default a system exception?

As I read from specification, EJB system exceptions are RemoteExceptions and RuntimeExceptions.

On the other hand, all PersistenceExceptions extends RuntimeException and rolls a transaction back (excluding NonUniqueResultException and NoResultException).

So does it is correct that PersistenceExceptions are EJB system exceptions as long as there is nothing else sp�ecified with an annotation or in deployment descriprot?

Christian
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you are right. PersistenceException is a RuntimeException and as such is a system exception from the EJB Container's point of view. However, don't forget that it is NOT an EJBException.

If your application uses session or mesage-driven beans and a call to an EntityManager method throws a PersistenceException (and if the bean rethrows that exception), the EJB Container will wrap the exception in an EJBException and rethrow it to the bean's client. Also, the bean will be discarded (as it is a system exception) and the transaction will be rolled back: in all cases(!), even if the PersistenceException was in fact a NonUniqueResultException or NoResultException. The reason behind that is that when the bean rethrows the PersistenceException, that is regarded as a system exception from the EJB Container point of view (and we know what happens with system exceptions).
reply
    Bookmark Topic Watch Topic
  • New Topic