• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System exception thrown inside a business method during a transaction

 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading chapter 13 Transaction Support of JSR 318. This specification does not say if the transaction will be rollback if a business method throws a system exception or runtime exception.

But it mentions this
an EJB marks a transaction for rollback to protect data integrity before throwing an application exception.


So, will the container rollback the transaction when an unexpected system / runtime exception occurs?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2533
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Himai,

Did you take that phrase from this section of the specs?
13.3.4.2 javax.ejb.EJBContext.setRollbackOnly Method
An enterprise bean with container-managed transaction demarcation can use the setRollbackOnlymethod of its EJBContext object to mark the transaction such that the transaction can never commit. Typically, an enterprise bean marks a transaction for rollback to protect data integrity before throwing an application exception, if the application exception class has not been specified to automatically cause the container to rollback the transaction.

This section is talking about the usage of the setRollbackOnly() method, not about system exceptions.

Chapter 14 deals with exceptions, and you might want to read 14.2.2 System Exceptions to answer your question.

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic