Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Throwing RemoveException in ejbRemove() with setRollbackOnly()

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an CMP ebean throws RemoveException in ejbRemove() but doesnt mark the txn for RollbackOnly, will the db record be removed eventually when the txn commits?

Which section of the spec can I find the info for this situation?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container always invokes ejbRemove() on session beans within an unspecified transaction context. This means that the container does not have to rollback any transaction in case RemoveException is thrown (section 7.6.1).

For entity beans the story is a little different as explained in sections 10.5.2 and 10.5.3. Moreover, 10.5.8.5 states the following:

From the client´┐Żs perspective, a RemoveException (or a subclass of RemoveException) indicates that an application level error occurred during a remove(...) operation. If a client receives this exception, the client does not know, in general, whether the entity object was removed or not. The client also does not know if the transaction has been marked for rollback. (However, the client may determine the transaction status using the UserTransaction interface.)

The Container or Bean Provider throws the RemoveException (or subclass of RemoveException) from a remove method to indicate an application-level error from the entity object removal operation. Optionally, the Container or Bean Provider may mark the transaction for rollback before throwing this exception.

The Container or Bean Provider is encouraged to mark the transaction for rollback only if data integrity would be lost if the transaction were committed by the client. Typically, when a RemoveException is thrown, it leaves the database in a consistent state, allowing the client to recover. The Container treats the RemoveException as any other application exception.


Hope this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic