/** * Get reference to physical connection. * <p/> * NOTE : be sure this handler is still valid before calling! * * @return The physical connection */ private Connection extractPhysicalConnection() { return logicalConnection.getConnection(); }
/** * Provide access to JDBCServices. * <p/> * NOTE : package-protected * * @return JDBCServices */ JdbcServices getJdbcServices() { return logicalConnection.getJdbcServices(); }
private void postProcessPreparedStatement(Statement statement) throws SQLException { logicalConnection.notifyObserversStatementPrepared(); postProcessStatement( statement ); }
protected void createTemporaryTableIfNecessary(final Queryable persister, final SessionImplementor session) { // Don't really know all the codes required to adequately decipher returned jdbc exceptions here. // simply allow the failure to be eaten and the subsequent insert-selects/deletes should fail TemporaryTableCreationWork work = new TemporaryTableCreationWork( persister ); if ( shouldIsolateTemporaryTableDDL() ) { session.getTransactionCoordinator() .getTransaction() .createIsolationDelegate() .delegateWork( work, getFactory().getSettings().isDataDefinitionInTransactionSupported() ); } else { final Connection connection = session.getTransactionCoordinator() .getJdbcCoordinator() .getLogicalConnection() .getShareableConnectionProxy(); work.execute( connection ); session.getTransactionCoordinator() .getJdbcCoordinator() .getLogicalConnection() .afterStatementExecution(); } }
public void afterNonTransactionalQuery(boolean success) { // check to see if the connection is in auto-commit mode (no connection means aggressive connection // release outside a JTA transaction context, so MUST be autocommit mode) boolean isAutocommit = getJdbcCoordinator().getLogicalConnection().isAutoCommit(); getJdbcCoordinator().getLogicalConnection().afterTransaction(); if ( isAutocommit ) { for ( TransactionObserver observer : observers ) { observer.afterCompletion( success, this.getTransaction() ); } } }
@Override public <T> T coordinateWork(WorkExecutorVisitable<T> work) { Connection connection = getLogicalConnection().getDistinctConnectionProxy(); try { T result = work.accept( new WorkExecutor<T>(), connection ); getLogicalConnection().afterStatementExecution(); return result; } catch ( SQLException e ) { throw sqlExceptionHelper().convert( e, "error executing work" ); } finally { try { if ( ! connection.isClosed() ) { connection.close(); } } catch (SQLException e) { LOG.debug( "Error closing connection proxy", e ); } } }
@Override public Connection connection() { errorIfClosed(); return transactionCoordinator.getJdbcCoordinator().getLogicalConnection().getDistinctConnectionProxy(); }
/** * Provide access to JDBCContainer. * <p/> * NOTE : package-protected * * @return JDBCContainer */ JdbcResourceRegistry getResourceRegistry() { return logicalConnection.getResourceRegistry(); }
public ConnectionProxyHandler(LogicalConnectionImplementor logicalConnection) { super( logicalConnection.hashCode() ); this.logicalConnection = logicalConnection; this.logicalConnection.addObserver( this ); }
protected final Connection connectionProxy() { return logicalConnection().getShareableConnectionProxy(); }
private void explicitClose(Statement proxy) { if ( isValid() ) { LogicalConnectionImplementor lc = getConnectionProxy().getLogicalConnection(); getResourceRegistry().release( proxy ); lc.afterStatementExecution(); } }
protected void createTemporaryTableIfNecessary(final Queryable persister, final SessionImplementor session) { // Don't really know all the codes required to adequately decipher returned jdbc exceptions here. // simply allow the failure to be eaten and the subsequent insert-selects/deletes should fail TemporaryTableCreationWork work = new TemporaryTableCreationWork( persister ); if ( shouldIsolateTemporaryTableDDL() ) { session.getTransactionCoordinator() .getTransaction() .createIsolationDelegate() .delegateWork( work, getFactory().getSettings().isDataDefinitionInTransactionSupported() ); } else { final Connection connection = session.getTransactionCoordinator() .getJdbcCoordinator() .getLogicalConnection() .getShareableConnectionProxy(); work.execute( connection ); session.getTransactionCoordinator() .getJdbcCoordinator() .getLogicalConnection() .afterStatementExecution(); } }
public void afterNonTransactionalQuery(boolean success) { // check to see if the connection is in auto-commit mode (no connection means aggressive connection // release outside a JTA transaction context, so MUST be autocommit mode) boolean isAutocommit = getJdbcCoordinator().getLogicalConnection().isAutoCommit(); getJdbcCoordinator().getLogicalConnection().afterTransaction(); if ( isAutocommit ) { for ( TransactionObserver observer : observers ) { observer.afterCompletion( success, this.getTransaction() ); } } }
@Override public <T> T coordinateWork(WorkExecutorVisitable<T> work) { Connection connection = getLogicalConnection().getDistinctConnectionProxy(); try { T result = work.accept( new WorkExecutor<T>(), connection ); getLogicalConnection().afterStatementExecution(); return result; } catch ( SQLException e ) { throw sqlExceptionHelper().convert( e, "error executing work" ); } finally { try { if ( ! connection.isClosed() ) { connection.close(); } } catch (SQLException e) { LOG.debug( "Error closing connection proxy", e ); } } }
@Override public SharedSessionBuilder connection() { return connection( session.transactionCoordinator .getJdbcCoordinator() .getLogicalConnection() .getDistinctConnectionProxy() ); }
/** * Provide access to JDBCContainer. * <p/> * NOTE : package-protected * * @return JDBCContainer */ JdbcResourceRegistry getResourceRegistry() { return logicalConnection.getResourceRegistry(); }
public ConnectionProxyHandler(LogicalConnectionImplementor logicalConnection) { super( logicalConnection.hashCode() ); this.logicalConnection = logicalConnection; this.logicalConnection.addObserver( this ); }
protected final Connection connectionProxy() { return logicalConnection().getShareableConnectionProxy(); }
private void explicitClose(Statement proxy) { if ( isValid() ) { LogicalConnectionImplementor lc = getConnectionProxy().getLogicalConnection(); getResourceRegistry().release( proxy ); lc.afterStatementExecution(); } }
/** * Provide access to JDBCServices. * <p/> * NOTE : package-protected * * @return JDBCServices */ JdbcServices getJdbcServices() { return logicalConnection.getJdbcServices(); }