Hi! All,
I got a question regarding to Container-transaction management. The database just
won't rollback when I use Container-transaction.
I am calling from a session bean (ApplicationService) to an entity bean
(ApplicationEntity) with ejbCreate().
...
ApplicationEntityHome home = getApplicationEntityHome();
try{
app = home.create(info);
} catch (Exception except) {
except.printStackTrace();
}
...
Here is ApplicationEntity.ejbCreate(ApplicationInfo) :
public String ejbCreate (ApplicationInfo info) throws
DuplicateKeyException,CreateException {
String applicationId = null;
allinfo = info;
try {
ApplicationControlDAO dao = new ApplicationControlDAO();
String applicationId = dao.insertApplicaton(allInfo);
BillingResults brt=BillingSystem.addUser(dao.getApplicationInfo());
}catch ( BillingException e) {
context.setRollbackOnly();
throw new CreateException("Billing Transaction failed!");
} catch (ApplicationDAOException daoe) {
System.out.println("ApplicationDAOException:" + daoe.getMessage());
}
return applicationId;
}
Under dao.insertApplicaton(allInfo), it will call some DAO objects to update different
database tables and it will fill some database generated data (like id, etc) for data
object 'allInfo'. However, even when the we catch the BillingSystem exception, the
context.setRollbackOnly() is executed and the CreateException("Billing Transaction
failed!") is thrown, the database updates won't rollback;
Here is the segment of my ejb-jar.xml:
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ApplicationEntity</ejb-name>
<method-name>ejbCreate</method-name>
<method-params>
<method-param>com.dataobject.ApplicationInfo</method-param>
</method-params>
<trans-attribute>Required</trans-attribute>
</method>
</container-transaction>
</assembly-descriptor>
My questions are:
(1) Anything wrong with my code/config?
(2) I used Orion 1.4.5 and PostgreSQL 7.1 database. Is that possible that something
wrong (or not support) with the transaction support for the PostgreSQL database or
JDBC driver?
(3) Any other better and quick solutions to my problem?
I appreciate if anyone can comment on the questions quickly. Thanks for your help!
Jim