aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes setRollbackOnly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "setRollbackOnly" Watch "setRollbackOnly" New topic
Author

setRollbackOnly

Sonika Saraswati
Greenhorn

Joined: Nov 22, 2004
Posts: 1
I am noticing one problem after calling setRollbackOnly method. here is the scenario.
=================================
SomeBean bean1;
initialize etc..
...

_ctx.setRollbackOnly();//_ctx is entity Context in this example.
throw new MyException("Exception info..."+bean1.getMethod1());
===================================

The throws clause is failing to execute bean1.getMethod1() after the roll back method. Where as if I move bean1.getMethod1() to above roll back method and pass the result of bean1.getMethod1() as a variable (someData) in throws clause, it works. Below is the working code.
=====================================
SomeBean bean1;
initialize etc..
...

String someData = bean1.getMethod1();
_ctx.setRollbackOnly();
throw new MyException("Exception info..."+someData);
=========================================

Any idea why this is happening?

Thanks.


-Sonika
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Spiffy! What container?


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
My guess is that getMethod1() is defined with CMT REQUIRED, REQUIRESNEW or MANDATORY, requiring that a valid transactional context be available. Since you've marked the context for rollback only, it cannot continue the transaction. Perhaps REQUIRESNEW is okay since it will suspend the current transaction to start a new one for that method.

This is a guess; I've been lucky to not come across that, and now we've moved to Spring + Hibernate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setRollbackOnly