java - Transaction across multiple EJBs -
recently refactoring code, came across transaction rollback scenario 1 ejb bean calls another. in exception block each bean has context marked rollback.
is practice or should re-throw exception & initiator bean rollback.
also, if there single transaction spanned across ejb's, rollback should happen @ originator bean or encountered exception.
transaction type jta persistence xa data source.
with
is marked rollback
you mean ejb catch exception , use setrollbackonly
?
if that's case, depends on design decide approach preferred.
normally transaction rolled if system exception detected container. application exception on opposite not have effect.
but, if business logic require business exception has important impact such must have effect of rolling whole transaction, have choice of setrollbackonly
, or launch application exception rollback=true
.
this second approach has effect of not destroying bean.
regarding second question:
also, if there single transaction spanned across ejb's, rollback should happen @ originator bean or encountered exception.
the rollback managed container, , again depends on design. keep in mind error may pass trough hole of unique bean in charge of rolling transaction, , not being catched @ all. end unwanted scenario transaction not being rolled @ all.
Comments
Post a Comment