Hello,
I've a EHB3 Stateless bean who's using direct JDBC connections (no persistence
manager) to store data in a database.
If I try to use TransactionManagement=CONTAINER Jboss seems to not execute roll
backs in case of exceptions (both Application or Runtime exception). I inserted
an as hoc thrown Exception to simulate the fault.
Managing TransactionManagement=BEAN works.
Any suggestion (code example below)?
CONTAINER mode (no rollback):
|
| @Stateless
| @javax.ejb.ApplicationException(rollback = true)
| @TransactionManagement(TransactionManagementType.CONTAINER)
| public class x implements y,z{
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Message processMessage() throws Exception
| {
|
| try {
| <<insert to DB>>
| << launch Exception>>
| } catch (Exception e1)
| {
| <<log>>
| throw e1;
| }}
|
|
BEAN mode (rollback executed):
|
| @Stateless
| @javax.ejb.ApplicationException(rollback = true)
| @TransactionManagement(TransactionManagementType.CONTAINER)
| public class x implements y,z{
|
| @Resource
| private UserTransaction utx;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Message processMessage() throws Exception
| {
|
| try {
| utx.begin();
| <<insert to DB>>
| << launch Exception>>
| utx.commit();
| } catch (Exception e1)
| {
| utx.rollback();
| <<log>>
| throw e1;
| }}
|
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091951#4091951
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091951
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user