use of org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess in project hibernate-orm by hibernate.
the class DateTimeParameterTest method dropProcedures.
private void dropProcedures(HibernateEntityManagerFactory emf) {
final SessionFactoryImplementor sf = emf.unwrap(SessionFactoryImplementor.class);
final JdbcConnectionAccess connectionAccess = sf.getServiceRegistry().getService(JdbcServices.class).getBootstrapJdbcConnectionAccess();
final Connection conn;
try {
conn = connectionAccess.obtainConnection();
conn.setAutoCommit(false);
try {
Statement statement = conn.createStatement();
dropProcedures(statement);
try {
statement.close();
} catch (SQLException ignore) {
}
} finally {
try {
conn.commit();
} catch (SQLException e) {
System.out.println("Unable to commit transaction afterQuery creating dropping procedures");
}
try {
connectionAccess.releaseConnection(conn);
} catch (SQLException ignore) {
}
}
} catch (SQLException e) {
throw new RuntimeException("Unable to drop stored procedures", e);
}
}
use of org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess in project hibernate-orm by hibernate.
the class MasterDetailTest method isSerializableIsolationEnforced.
protected boolean isSerializableIsolationEnforced() throws Exception {
JdbcConnectionAccess connectionAccess = sessionFactory().getServiceRegistry().getService(JdbcServices.class).getBootstrapJdbcConnectionAccess();
Connection conn = null;
try {
conn = connectionAccess.obtainConnection();
return conn.getTransactionIsolation() >= Connection.TRANSACTION_SERIALIZABLE;
} finally {
if (conn != null) {
try {
connectionAccess.releaseConnection(conn);
} catch (Throwable ignore) {
// ignore...
}
}
}
}
use of org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess in project hibernate-orm by hibernate.
the class JpaTckUsageTest method createProcedures.
private void createProcedures(HibernateEntityManagerFactory emf) {
final SessionFactoryImplementor sf = emf.unwrap(SessionFactoryImplementor.class);
final JdbcConnectionAccess connectionAccess = sf.getServiceRegistry().getService(JdbcServices.class).getBootstrapJdbcConnectionAccess();
final Connection conn;
try {
conn = connectionAccess.obtainConnection();
conn.setAutoCommit(false);
try {
Statement statement = conn.createStatement();
// drop them, just to be sure
try {
dropProcedures(statement);
} catch (SQLException ignore) {
}
createProcedureFindOneUser(statement);
createProcedureDeleteAllUsers(statement);
try {
statement.close();
} catch (SQLException ignore) {
}
} finally {
try {
conn.commit();
} catch (SQLException e) {
System.out.println("Unable to commit transaction afterQuery creating creating procedures");
}
try {
connectionAccess.releaseConnection(conn);
} catch (SQLException ignore) {
}
}
} catch (SQLException e) {
throw new RuntimeException("Unable to create stored procedures", e);
}
}
use of org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess in project hibernate-orm by hibernate.
the class JpaTckUsageTest method dropProcedures.
private void dropProcedures(HibernateEntityManagerFactory emf) {
final SessionFactoryImplementor sf = emf.unwrap(SessionFactoryImplementor.class);
final JdbcConnectionAccess connectionAccess = sf.getServiceRegistry().getService(JdbcServices.class).getBootstrapJdbcConnectionAccess();
final Connection conn;
try {
conn = connectionAccess.obtainConnection();
conn.setAutoCommit(false);
try {
Statement statement = conn.createStatement();
dropProcedures(statement);
try {
statement.close();
} catch (SQLException ignore) {
}
} finally {
try {
conn.commit();
} catch (SQLException e) {
System.out.println("Unable to commit transaction afterQuery creating dropping procedures");
}
try {
connectionAccess.releaseConnection(conn);
} catch (SQLException ignore) {
}
}
} catch (SQLException e) {
throw new RuntimeException("Unable to drop stored procedures", e);
}
}
use of org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess in project hibernate-orm by hibernate.
the class StoreProcedureOutParameterByNameTest method createProcedure.
private void createProcedure(EntityManagerFactory emf, String storedProc) {
final SessionFactoryImplementor sf = emf.unwrap(SessionFactoryImplementor.class);
final JdbcConnectionAccess connectionAccess = sf.getServiceRegistry().getService(JdbcServices.class).getBootstrapJdbcConnectionAccess();
final Connection conn;
try {
conn = connectionAccess.obtainConnection();
conn.setAutoCommit(false);
try {
Statement statement = conn.createStatement();
statement.execute(storedProc);
try {
statement.close();
} catch (SQLException ignore) {
fail();
}
} finally {
try {
conn.commit();
} catch (SQLException e) {
System.out.println("Unable to commit transaction after creating creating procedures");
fail();
}
try {
connectionAccess.releaseConnection(conn);
} catch (SQLException ignore) {
fail();
}
}
} catch (SQLException e) {
throw new RuntimeException("Unable to create stored procedures", e);
}
}
Aggregations