entityManager.getTransaction().begin(); UnitOfWork unitOfWork = (UnitOfWork)((JpaEntityManager)entityManager.getDelegate()).getActiveSession(); unitOfWork.beginEarlyTransaction(); Accessor accessor = unitOfWork.getAccessor(); accessor.incrementCallCount(unitOfWork.getParent()); accessor.decrementCallCount(); java.sql.Connection connection = accessor.getConnection(); ... entityManager.getTransaction().commit();
/** * INTERNAL: * Because connections are not exclusive nothing is required. */ public synchronized void releaseConnection(Accessor connection) throws DatabaseException { connection.decrementCallCount(); if (!connection.isValid()){ getOwner().setCheckConnections(); this.connectionsAvailable.remove(connection); try{ connection.disconnect(getOwner()); }catch (Exception ex){ //ignore } } } }
/** * INTERNAL: * Because connections are not exclusive nothing is required. */ public synchronized void releaseConnection(Accessor connection) throws DatabaseException { if (this.owner.shouldLog(SessionLog.FINEST, SessionLog.CONNECTION)) { Object[] args = new Object[1]; args[0] = this.name; this.owner.log(SessionLog.FINEST, SessionLog.CONNECTION, "release_connection", args, connection); } connection.decrementCallCount(); if (!connection.isValid()){ this.checkConnections = true; this.connectionsAvailable.remove(connection); try{ connection.disconnect(getOwner()); }catch (Exception ex){ //ignore } } } }
/** * INTERNAL: * Because connections are not exclusive nothing is required. */ public synchronized void releaseConnection(Accessor connection) throws DatabaseException { if (this.owner.shouldLog(SessionLog.FINEST, SessionLog.CONNECTION)) { Object[] args = new Object[1]; args[0] = this.name; this.owner.log(SessionLog.FINEST, SessionLog.CONNECTION, "release_connection", args, connection); } connection.decrementCallCount(); if (!connection.isValid()){ this.checkConnections = true; this.connectionsAvailable.remove(connection); try{ connection.disconnect(getOwner()); }catch (Exception ex){ //ignore } } } }
accessor.decrementCallCount(); return (T) accessor.getConnection(); accessor.decrementCallCount(); return (T) accessor.getDatasourceConnection();
/** * INTERNAL: * Remove the event listener from the database. */ public void remove(Session session) { if (this.register == null) { return; } AbstractSession databaseSession = (AbstractSession)session; Accessor accessor = databaseSession.getAccessor(); accessor.incrementCallCount(databaseSession); try { OracleConnection connection = (OracleConnection)databaseSession.getServerPlatform().unwrapConnection(accessor.getConnection()); databaseSession.log(SessionLog.FINEST, SessionLog.CONNECTION, "dcn_unregister"); try { connection.unregisterDatabaseChangeNotification(this.register); } catch (SQLException exception) { throw DatabaseException.sqlException(exception, databaseSession.getAccessor(), databaseSession, false); } } finally { accessor.decrementCallCount(); } }
/** * INTERNAL: * Remove the event listener from the database. */ @Override public void remove(Session session) { if (this.register == null) { return; } AbstractSession databaseSession = (AbstractSession)session; Accessor accessor = databaseSession.getAccessor(); accessor.incrementCallCount(databaseSession); try { OracleConnection connection = (OracleConnection)databaseSession.getServerPlatform().unwrapConnection(accessor.getConnection()); databaseSession.log(SessionLog.FINEST, SessionLog.CONNECTION, "dcn_unregister"); try { connection.unregisterDatabaseChangeNotification(this.register); } catch (SQLException exception) { throw DatabaseException.sqlException(exception, databaseSession.getAccessor(), databaseSession, false); } } finally { accessor.decrementCallCount(); } }