Hmmm... This might be reaching a bit. Someone else can probably come up with a better example. Personally, I think that it's probably there for symmetry with the
EJB interface, but...
If you are using BMT, then sometimes you may be way deep inside of a transaction and discover that you need to roll the transaction back. Well, the problem is one of scope -- if you invoke a rollback() deep inside your call tree everything will proceed hunky-dory until later back up in the call tree someone tries to do a commit() -- and then they'll get an uninformative
IllegalStateException thrown at the commit.
So instead, when you get to a point where you decide a transaction cannot commit (for instance, the spec talks about doing this prior to throwing an exception) you can mark the transaction as rollback only -- even if your code doesn't look to see the transaction state and tries to commit, it will still end up rolling back -- and the commit() will throw the slightly more meaningful "RollbackException".
Kyle
------------------
Kyle Brown,
Author of
Enterprise Java (tm) Programming with IBM Websphere See my homepage at
http://members.aol.com/kgb1001001 for other WebSphere information.