/** * If we created a transaction commit it. We have successfully processed all * the rows. */ protected void commitTransactionIfCreated() { if (createdTransaction) { transaction.commit(); logger.info("Committed transaction"); } }
/** * Execute the find Id's query returning the list of Id's. */ public List<Object> call() throws Exception { // we have already made a copy of the query // this way the same query instance is available to the // QueryFutureIds (as so has access to the List before it is done) try { return server.findIdsWithCopy(query, transaction); } finally { transaction.end(); } }
/** * Create a transaction if one is not already active and set its batch mode * and batch size. */ protected void initTransactionIfRequired() { transaction = server.currentTransaction(); if (transaction == null || !transaction.isActive()) { transaction = server.beginTransaction(); createdTransaction = true; if (persistBatchSize > 1) { logger.info("Creating transaction, batchSize[" + persistBatchSize + "]"); transaction.setBatchMode(true); transaction.setBatchSize(persistBatchSize); transaction.setBatchGetGeneratedKeys(false); } else { // explicitly turn off JDBC batching in case // is has been turned on globally transaction.setBatchMode(false); logger.info("Creating transaction with no JDBC batching"); } } }
/** * Create a transaction if one is not already active and set its batch mode * and batch size. */ protected void initTransactionIfRequired() { transaction = server.currentTransaction(); if (transaction == null || !transaction.isActive()) { transaction = server.beginTransaction(); createdTransaction = true; if (persistBatchSize > 1) { logger.info("Creating transaction, batchSize[" + persistBatchSize + "]"); transaction.setBatchMode(true); transaction.setBatchSize(persistBatchSize); } else { // explicitly turn off JDBC batching in case // is has been turned on globally transaction.setBatchMode(false); logger.info("Creating transaction with no JDBC batching"); } } }
/** * Execute all the DDL statements in the script. */ public void runScript(boolean expectErrors, String content) { StringReader sr = new StringReader(content); List<String> statements = parseStatements(sr); Transaction t = server.createTransaction(); try { Connection connection = t.getConnection(); out.println("runScript"); out.flush(); runStatements(expectErrors, statements, connection); out.println("... end of script"); out.flush(); t.commit(); } catch (Exception e){ String msg = "Error: "+e.getMessage(); throw new PersistenceException(msg, e); } finally { t.end(); } }
ResultSet rset = null; try { c = useTxnConnection ? t.getConnection() : dataSource.getConnection();
/** * Rollback the transaction if we where not successful in processing all the * rows. */ protected void rollbackTransactionIfCreated(Throwable e) { if (createdTransaction) { transaction.rollback(e); logger.info("Rolled back transaction"); } }
/** * Log a comment to the transaction log (of the current transaction). */ public void logComment(String msg) { Transaction t = transactionScopeManager.get(); if (t != null) { t.log(msg); } }
/** * Execute all the DDL statements in the script. */ public void runScript(boolean expectErrors, String content) { StringReader sr = new StringReader(content); List<String> statements = parseStatements(sr); Transaction t = server.createTransaction(); try { Connection connection = t.getConnection(); out.println("runScript"); out.flush(); runStatements(expectErrors, statements, connection); out.println("... end of script"); out.flush(); t.commit(); } catch (Exception e){ String msg = "Error: "+e.getMessage(); throw new PersistenceException(msg, e); } finally { t.end(); } }
ResultSet rset = null; try { c = useTxnConnection ? t.getConnection() : dataSource.getConnection();
/** * Create a transaction if one is not already active and set its batch mode * and batch size. */ protected void initTransactionIfRequired() { transaction = server.currentTransaction(); if (transaction == null || !transaction.isActive()) { transaction = server.beginTransaction(); createdTransaction = true; if (persistBatchSize > 1) { logger.info("Creating transaction, batchSize[" + persistBatchSize + "]"); transaction.setBatchMode(true); transaction.setBatchSize(persistBatchSize); } else { // explicitly turn off JDBC batching in case // is has been turned on globally transaction.setBatchMode(false); logger.info("Creating transaction with no JDBC batching"); } } }
/** * Rollback the transaction if we where not successful in processing all the * rows. */ protected void rollbackTransactionIfCreated(Throwable e) { if (createdTransaction) { transaction.rollback(e); logger.info("Rolled back transaction"); } }
/** * Log a comment to the transaction log (of the current transaction). */ public void logComment(String msg) { Transaction t = transactionScopeManager.get(); if (t != null) { t.log(msg); } }
/** * Execute all the DDL statements in the script. */ public int runScript(boolean expectErrors, String content, String scriptName) { DdlRunner runner = new DdlRunner(expectErrors, scriptName); Transaction transaction = server.createTransaction(); Connection connection = transaction.getConnection(); try { if (expectErrors) { connection.setAutoCommit(true); } int count = runner.runAll(content, connection); if (expectErrors) { connection.setAutoCommit(false); } transaction.commit(); return count; } catch (SQLException e) { throw new PersistenceException("Failed to run script", e); } finally { transaction.end(); } }
public Object nextId(Transaction t) { boolean useTxnConnection = t != null; Connection c = null; PreparedStatement pstmt = null; ResultSet rset = null; try { c = useTxnConnection ? t.getConnection() : dataSource.getConnection(); pstmt = c.prepareStatement(sql); rset = pstmt.executeQuery(); if (rset.next()){ int val = rset.getInt(1); return Integer.valueOf(val); } else { String m = "Always expecting 1 row from "+sql; throw new PersistenceException(m); } } catch (SQLException e){ throw new PersistenceException("Error getting sequence nextval", e); } finally { if (useTxnConnection){ closeResources(rset, pstmt, null); } else { closeResources(rset, pstmt, c); } } }
/** * If we created a transaction commit it. We have successfully processed all * the rows. */ protected void commitTransactionIfCreated() { if (createdTransaction) { transaction.commit(); logger.info("Committed transaction"); } }
/** * Execute the query returning the resulting List. */ public List<T> call() throws Exception { try { return server.findList(query, transaction); } finally { // cleanup the underlying connection transaction.end(); } }
/** * Rollback the transaction if we where not successful in processing all the * rows. */ protected void rollbackTransactionIfCreated(Throwable e) { if (createdTransaction) { transaction.rollback(e); logger.info("Rolled back transaction"); } }
public Object nextId(Transaction t) { boolean useTxnConnection = t != null; Connection c = null; PreparedStatement pstmt = null; ResultSet rset = null; try { c = useTxnConnection ? t.getConnection() : dataSource.getConnection(); pstmt = c.prepareStatement(sql); rset = pstmt.executeQuery(); if (rset.next()) { int val = rset.getInt(1); return Integer.valueOf(val); } else { String m = "Always expecting 1 row from " + sql; throw new PersistenceException(m); } } catch (SQLException e) { throw new PersistenceException("Error getting sequence nextval", e); } finally { if (useTxnConnection) { closeResources(rset, pstmt, null); } else { closeResources(rset, pstmt, c); } } }
/** * If we created a transaction commit it. We have successfully processed all * the rows. */ protected void commitTransactionIfCreated() { if (createdTransaction) { transaction.commit(); logger.info("Committed transaction"); } }