I have a problem when testing JTA1.2 @Transactiona
l annotation on Glassfish 4.1 application server.
If I run execute() method of this bean:
@Named
@RequestScoped
public class IndexController {
@Resource(name = "ds")
private DataSource ds;
@Transactional
public void execute() throws SQLException, SystemException {
try (Connection con = ds.getConnection();) {
try (PreparedStatement ps = con.prepareStatement(
"INSERT INTO test(id) VALUES(1)"
);) {
ps.executeUpdate();
throw new IllegalArgumentException();
}
}
}
}
I get expected error:
Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
but when I execute select statement:
SELECT * FROM test;
I see that row was inserted. What's wrong?