HHH-15869 Use explicit transactions for all SQL operations

The test fails on e.g. CockroachDB 21.2 because first DDL is in a Transaction
but not the other DML/DDL statements.
This commit is contained in:
Karel Maesen 2022-12-14 18:41:39 +01:00 committed by Christian Beikov
parent 7a7acfe120
commit 723ca11f34
1 changed files with 4 additions and 1 deletions

View File

@ -78,6 +78,7 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase {
assertTrue( jdbcCoord.getLogicalConnection().isPhysicallyConnected() ); // after_transaction specified
ddlTxn.commit();
Transaction dmlTxn = session.beginTransaction();
PreparedStatement ps = jdbcCoord.getStatementPreparer().prepareStatement(
"insert into SANDBOX_JDBC_TST( ID, NAME ) values ( ?, ? )" );
ps.setLong( 1, 1 );
@ -86,19 +87,21 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase {
ps = jdbcCoord.getStatementPreparer().prepareStatement( "select * from SANDBOX_JDBC_TST" );
jdbcCoord.getResultSetReturn().extract( ps );
assertTrue( getResourceRegistry( jdbcCoord ).hasRegisteredResources() );
dmlTxn.commit();
}
catch ( SQLException e ) {
fail( "incorrect exception type : sqlexception" );
}
finally {
try {
Transaction ddlTx = session.beginTransaction();
session.doWork( connection -> {
final Statement stmnt = connection.createStatement();
stmnt.execute( sessionFactory().getJdbcServices().getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) );
} );
ddlTx.commit();
}
finally {
session.close();