@Override public SelectStatement getPreparedSelectStatement(Query query, ClassDescriptor cld) { SelectStatement sql = new SuffixedSqlSelectStatement(getPlatform(), cld, query, logger); if (logger.isDebugEnabled()) { boolean masochisticSqlLogging = true; if ( masochisticSqlLogging ) { logger.debug("SQL: " + sql.getStatement() + "\n" + query.getCriteria() + "\nFor platform: " + getPlatform().getClass().toString() + "\n" + ExceptionUtils.getStackTrace(new Throwable())); } else { logger.debug("SQL: " + sql.getStatement() ); } } return sql; } }
/** * Check if underlying connection was alive. */ public boolean isAlive(Connection conn) { try { return con != null ? !con.isClosed() : false; } catch (SQLException e) { log.error("IsAlive check failed, running connection was invalid!!", e); return false; } }
if (log.isDebugEnabled()) log.debug("commit was called"); if (!this.isInLocalTransaction) log.error("Commit on underlying connection failed, try to rollback connection", e); this.localRollback(); throw new TransactionAbortedException("Commit on connection failed", e);
stmt = broker.serviceStatementManager().getSelectByPKStatement(cld); if (stmt == null) { if (logger.isEnabledFor(Logger.ERROR)) { logger.error("getSelectByPKStatement returned a null statement"); if (logger.isEnabledFor(Logger.ERROR)) { logger.error("PersistenceBrokerException during the execution of materializeObject: " + e.getMessage(), e); if (logger.isEnabledFor(Logger.ERROR)) { logger.error("SQLException during the execution of materializeObject (for a " + cld.getClassOfObject().getName() + "): " + e.getMessage(), e);
/** * Start transaction on the underlying connection. */ public void localBegin() { if (this.isInLocalTransaction) { throw new TransactionInProgressException("Connection is already in transaction"); } Connection connection = null; try { connection = this.getConnection(); } catch (LookupException e) { /** * must throw to notify user that we couldn't start a connection */ throw new PersistenceBrokerException("Can't lookup a connection", e); } if (log.isDebugEnabled()) log.debug("localBegin was called for con " + connection); if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE) { if (log.isDebugEnabled()) log.debug("Try to change autoCommit state to 'false'"); platform.changeAutoCommitState(jcd, connection, false); } this.isInLocalTransaction = true; }
/** * Release connection to the {@link org.apache.ojb.broker.accesslayer.ConnectionFactory}, make * sure that you call the method in either case, it's the only way to free the connection. */ public void releaseConnection() { if (this.con == null) { return; } if(isInLocalTransaction()) { log.error("Release connection: connection is in local transaction, missing 'localCommit' or" + " 'localRollback' call - try to rollback the connection"); localRollback(); } else { this.connectionFactory.releaseConnection(this.jcd, this.con); this.con = null; this.batchCon = null; } }
if (log.isDebugEnabled()) log.debug("Request new connection from ConnectionFactory: " + con);