/** * INTERNAL: * Called by beginTransaction() to start a transaction. * This starts a real database transaction. */ protected void basicBeginTransaction() throws DatabaseException { try { getAccessor().beginTransaction(this); } catch (RuntimeException exception) { handleException(exception); } }
/** * INTERNAL: * When we acquire a connection from an ExternalConnectionPool we build * a new connection (retrieve it from the external pool). */ public synchronized Accessor acquireConnection() throws ConcurrencyException { return (Accessor)getCachedConnection().clone(); }
/** * INTERNAL: * When you release an external connection, you simply let it go. */ public synchronized void releaseConnection(Accessor connection) throws DatabaseException { getConnectionsUsed().removeElement(connection); connection.closeConnection(); notify(); }
accessor.beginTransaction(writeSession); Vector sequences = sequence.getGeneratedVector(accessor, writeSession); getPreallocationHandler().setPreallocated(seqName, sequences); accessor.commitTransaction(writeSession); logDebugPreallocation(seqName, sequences); } catch (RuntimeException ex) { try { accessor.rollbackTransaction(writeSession); } catch (Exception rollbackException) {
/** * INTERNAL: * Disconnect the accessor only (this must be the write connection as the read is shared). */ public void disconnect() throws DatabaseException { getWriteConnection().disconnect(this); }
public void onConnect() { if (!isConnected()) { accessor.connect(login, ownerSession); } }
/** * INTERNAL: * Overridden by subclasses that do more than just execute the call. * Executes the call directly on this session and does not check which * session it should have executed on. */ public Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException { //** sequencing refactoring if (query.getAccessor() == null) { query.setAccessor(getAccessor()); } try { return query.getAccessor().executeCall(call, translationRow, this); } finally { if (call.isFinished()) { query.setAccessor(null); } } }
executionSession.getAccessor().flushSelectCalls(executionSession); return returnedRowCount;
/** * INTERNAL: * Because connections are not exclusive nothing is required. */ public synchronized void releaseConnection(Accessor connection) throws DatabaseException { connection.decrementCallCount(); } }
/** * INTERNAL: * Called by commitTransaction() to commit a transaction. * This commits the active transaction. */ protected void basicCommitTransaction() throws DatabaseException { try { getAccessor().commitTransaction(this); } catch (RuntimeException exception) { handleException(exception); } }
/** * INTERNAL: * Called after transaction is completed (committed or rolled back) */ public void afterTransaction(boolean committed, boolean isExternalTransaction) { if (hasWriteConnection()) { getParent().afterTransaction(committed, isExternalTransaction, getWriteConnection()); if (isExternalTransaction) { getWriteConnection().afterJTSTransaction(); releaseWriteConnection(); } } }
public void onDisconnect() { if (isConnected()) { accessor.disconnect(ownerSession); } }
/** * INTERNAL: * Connect the session only. */ public void connect() throws DatabaseException { getAccessor().connect(getDatasourceLogin(), this); }
protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) { DatabaseQuery query = dbCall.getQuery(); if (!query.isWriteObjectQuery()) { //if not writequery, should not go through the locator writing.. return; } WriteObjectQuery writeQuery = (WriteObjectQuery)query; writeQuery.setAccessor(accessor); //build a select statement form the query SQLSelectStatement selectStatement = buildSelectStatementForLocator(writeQuery, dbCall, session); //then build a call from the statement DatabaseCall call = buildCallFromSelectStatementForLocator(selectStatement, writeQuery, dbCall, session); accessor.executeCall(call, call.getQuery().getTranslationRow(), session); }
executionSession.getAccessor().flushSelectCalls(executionSession);
/** * INTERNAL: * Disconnect all connections. */ public synchronized void shutDown() { setIsConnected(false); for (Enumeration avaiableEnum = getConnectionsAvailable().elements(); avaiableEnum.hasMoreElements();) { try { ((Accessor)avaiableEnum.nextElement()).disconnect(getOwner()); } catch (DatabaseException exception) { // Ignore. } } for (Enumeration usedEnum = getConnectionsUsed().elements(); usedEnum.hasMoreElements();) { try { ((Accessor)usedEnum.nextElement()).disconnect(getOwner()); } catch (DatabaseException exception) { // Ignore. } } resetConnections(); }
/** * INTERNAL: * Connect the session only (this must be the write connection as the read is shared). */ public void connect() throws DatabaseException { getWriteConnection().connect(getDatasourceLogin(), this); }
object = query.getAccessor().executeCall(call, translationRow, this); } catch (RuntimeException caughtException) { exception = caughtException;
/** * INTERNAL: * Disconnect the accessor only. */ public void disconnect() throws DatabaseException { getSequencingHome().onDisconnect(); getAccessor().disconnect(this); }
/** * INTERNAL: * Create a new connection, accessors are used as connections. */ protected Accessor buildConnection() { Login localLogin = (Login)getLogin().clone(); Accessor connection = localLogin.buildAccessor(); connection.connect(localLogin, getOwner()); return connection; }