CDI @ Transactional.rollbackOn not working
I am using the following source to try out @Transactional
@Transactional(value = TxType.REQUIRED, rollbackOn = { SQLException.class })
public void insert_Required() throws Exception {
insert("INSERT_REQUIRED");
int i = 1;
if (i == 1) {
throw new SQLException("error");
}
return;
}
private void insert(final String description) throws SQLException {
PreparedStatement pst = connection.prepareStatement(INSERT_STMT);
pst.setString(1, description);
pst.execute();
}
Unfortunately, the record will be inserted and committed instead of canceling the transaction. What's wrong there?
+3
source to share