I'm using JBoss 4.0.1 with MySQL 4.1.8. I also checked to make sure all my tables were InnoDB.
For some reason or another, the following code does not rollback changes made to the myEJB entity bean:
/** * @ejb.interface-method view-type = "both" * @ejb.transaction type = "Required" */ public void completeRequest(MyDTO dto) throws MyException { myEJB.setApprovedBy(approvedBy); myEJB.setApprovedAmount(amount); myEJB.setDateApproved(currentTime); myEJB.setStatus(REQUEST_COMPLETED); myEJB.setComments(dto.getComments()); try { ....(call to another session facade) } catch (MyException e) { context.setRollbackOnly(); throw e; } } }
BEGIN; INSERT INTO myTable(subject) VALUES ('test'); ROLLBACK;
16:14:03,015 DEBUG [MyEJB#findRequestsByStatus] Executing SQL: SELECT t0_o.requestID FROM myTable t0_o WHERE (t0_o.status = ?) 16:14:03,015 DEBUG [MyEJB#findRequestsByStatusAndType] Executing SQL: SELECT t0_o.requestID FROM myTable t0_o WHERE (t0_o.status = ? AND t0_o.type = ?) 16:14:31,656 DEBUG [FinanceRequestBean] Executing SQL: UPDATE myTable SET comments=?, status=? WHERE requestID=?