protected Object processResultSet(ResultSet resultSet, DatabaseCall dbCall, PreparedStatement statement, DatabaseAccessor accessor, AbstractSession session) throws SQLException { Object result = null; ResultSetMetaData metaData = resultSet.getMetaData(); session.startOperationProfile(SessionProfiler.ROW_FETCH); try { if (dbCall.isOneRowReturned()) { if (resultSet.next()) { result = accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session); if (resultSet.next()) { // Raise more rows event, some apps may interpret as error or warning. session.getEventManager().moreRowsDetected(dbCall); } } else { result = null; } } else { Vector results = new Vector(20); while (resultSet.next()) { results.addElement(accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session)); } result = results; } resultSet.close();// This must be closed incase the statement is cached and not closed. } finally { session.endOperationProfile(SessionProfiler.ROW_FETCH); } return result; }
getEventManager().missingDescriptor(theClass); descriptor = (ClassDescriptor)getDescriptors().get(theClass);
/** * Execute the statement. */ protected ResultSet executeSelect(DatabaseCall call, Statement statement, AbstractSession session) throws SQLException { ResultSet resultSet; session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE); try { if (call.isDynamicCall(session)) { resultSet = statement.executeQuery(call.getSQLString()); } else { resultSet = ((PreparedStatement)statement).executeQuery(); } } finally { session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE); } // Allow for procs with outputs to be raised as events for error handling. if (call.shouldBuildOutputRow()) { AbstractRecord outputRow = buildOutputRow((CallableStatement)statement, call, session); call.getQuery().setProperty("output", outputRow); session.getEventManager().outputParametersDetected(outputRow, call); } return resultSet; }
/** * Execute the statement. */ protected Integer executeNoSelect(DatabaseCall call, Statement statement, AbstractSession session) throws DatabaseException { Integer rowCount = executeDirectNoSelect(statement, call, session); // Allow for procs with outputs to be raised as events for error handling. if (call.shouldBuildOutputRow()) { AbstractRecord outputRow = buildOutputRow((CallableStatement)statement, call, session); call.getQuery().setProperty("output", outputRow); session.getEventManager().outputParametersDetected(outputRow, call); } return rowCount; }
/** * PUBLIC: * Commit the active database transaction. * This allows a group of database modification to be commited or rolledback as a unit. * All writes/deletes will be sent to the database be will not be visible to other users until commit. * Although databases do not allow nested transaction, * TopLink supports nesting through only committing to the database on the outer commit. * * @exception DatabaseException most databases validate changes as they are done, * normally errors do not occur on commit unless the disk fails or the connection is lost. * @exception ConcurrencyException if this session is not within a transaction. */ public void commitTransaction() throws DatabaseException, ConcurrencyException { // Release mutex and call subclass specific commit. if (!getTransactionMutex().isNested()) { getEventManager().preCommitTransaction(); basicCommitTransaction(); getEventManager().postCommitTransaction(); } // This MUST not be in a try catch or finally as if the commit failed the transaction is still open. getTransactionMutex().release(); // If there is no db transaction in progress // if there is an active external transaction // which was started internally - it should be committed internally, too. if (!isInTransaction()) { commitExternalTransaction(); } }
/** * PUBLIC: * Rollback the active database transaction. * This allows a group of database modification to be commited or rolledback as a unit. * All writes/deletes will be sent to the database be will not be visible to other users until commit. * Although databases do not allow nested transaction, * TopLink supports nesting through only committing to the database on the outer commit. * * @exception DatabaseException if the database connection is lost or the rollback fails. * @exception ConcurrencyException if this session is not within a transaction. */ public void rollbackTransaction() throws DatabaseException, ConcurrencyException { // Ensure release of mutex and call subclass specific release. try { if (!getTransactionMutex().isNested()) { getEventManager().preRollbackTransaction(); basicRollbackTransaction(); getEventManager().postRollbackTransaction(); } } finally { getTransactionMutex().release(); // If there is no db transaction in progress // if there is an active external transaction // which was started internally - it should be rolled back internally, too. if (!isInTransaction()) { rollbackExternalTransaction(); } } }
/** * PUBLIC: * Reconnect to the database. This can be used if the connection was disconnected or timedout. * This ensures that the security is checked as it is public. * Because the messages can take a long time to build, * pre-check whether messages should be logged. */ public void reestablishConnection(AbstractSession session) throws DatabaseException { if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required. Object[] args = { getLogin() }; session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "reconnecting", args, this); } reconnect(session); setIsInTransaction(false); session.getEventManager().postConnect(this); }
getEventManager().preBeginTransaction(); basicBeginTransaction(); getEventManager().postBeginTransaction();
AbstractRecord outputRow = accessor.buildOutputRow((CallableStatement)statement, dbCall, session); dbCall.getQuery().setProperty("output", outputRow); session.getEventManager().outputParametersDetected(outputRow, dbCall);
getParent().getEventManager().preMergeUnitOfWorkChangeSet(uowChangeSet); if (!isNestedUnitOfWork() && getDatasourceLogin().shouldSynchronizeObjectLevelReadWrite()) { setMergeManager(manager); getParent().getEventManager().postMergeUnitOfWorkChangeSet(uowChangeSet); endOperationProfile(SessionProfiler.Merge);
getSession().getEventManager().preDistributedMergeUnitOfWorkChangeSet(uowChangeSet); getSession().getIdentityMapAccessorInstance().getWriteLockManager().releaseAllAcquiredLocks(this); getSession().getIdentityMapAccessorInstance().releaseWriteLock(); getSession().getEventManager().postDistributedMergeUnitOfWorkChangeSet(uowChangeSet); getSession().endOperationProfile(SessionProfiler.DistributedMerge);
session.getEventManager().moreRowsDetected(dbCall);
/** * Connect to the datasource. Through using a CCI ConnectionFactory. * Catch exceptions and re-throw as TopLink exceptions. */ public void connect(Login login, AbstractSession session) throws DatabaseException { session.startOperationProfile(SessionProfiler.CONNECT); session.incrementProfile(SessionProfiler.TlConnects); try { if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required. session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "connecting", new Object[] { login }, this); } setLogin(login); this.setDatasourcePlatform((DatasourcePlatform)session.getDatasourceLogin().getDatasourcePlatform()); try { connect(login); setIsInTransaction(false); } catch (RuntimeException exception) { session.handleSevere(exception); } session.getEventManager().postConnect(this); incrementCallCount(session); try { buildConnectLog(session); } finally { decrementCallCount(); } } finally { session.endOperationProfile(SessionProfiler.CONNECT); } }
getEventManager().preExecuteQuery(query); Object result; if (isInProfile()) { result = internalExecuteQuery(query, row); getEventManager().postExecuteQuery(query, result); return result; } catch (RuntimeException exception) {
this.isInProfile = parent.isInProfile; this.sessionLog = parent.getSessionLog(); this.eventManager = parent.getEventManager().clone(this); this.exceptionHandler = parent.getExceptionHandler();
getSession().getEventManager().noRowsModified(writeQuery, object);
getSession().getEventManager().noRowsModified(writeQuery, object);
getSession().getEventManager().noRowsModified(writeQuery, object);