I hope this is the correct forum.
I have a SLSB set to use CMT for the following method:
public void clearDatabase() throws RemoteException{
Connection connection = null;
DatabaseConstraintManager constraintMgr = new DatabaseConstraintManager(connection);
addConstraints(constraintMgr);
try{
constraintMgr.disableConstraints();
truncateTables(connection);
constraintMgr.enableConstrants(); // << Exception happens here
} catch(SQLException e){
e.printStackTrace();
sessionContext.setRollbackOnly();
} finally{
try{
connection.close();
} catch(SQLException e1){
e1.printStackTrace();
}
}
Even though an exception happens after truncateTables I'm expecting the tables to still be populated since all 3 methods should be covered in one CMT.
Here is what I have set in ejb-jar.xml:
<display-name>AdminHandler</display-name>
<ejb-name>AdminHandler</ejb-name>
... snip...
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
...
<container-transaction>
<ejb-name>AdminHandler</ejb-name>
<method-name>clearDatabase</method-name>
<trans-attribute>Required</trans-attribute>
Any advice is much appreciated,
Andrew