private DelegatingDbSessionSupplier buildBatchDbSessionSupplier() { return new DelegatingDbSessionSupplier(() -> { DbSession res = myBatis.openSession(true); ensureAutoCommitFalse(res); return res; }); }
@Override public void close() { try { iterator.close(); } finally { DatabaseUtils.closeQuietly(stmt); session.close(); } }
@Override public int insert(String statement) { makeSureGeneratedKeysAreNotUsedInBatchInserts(statement); increment(); return super.insert(statement); }
@Override public void doClose() { // rollback when session is dirty so that no statement leaks from one use of the DbSession to another // super.close() would do such rollback before actually closing **if autocommit is true** // we are going to assume autocommit is true and keep this behavior if (dirty) { getDelegate().rollback(); } }
@Override public <E> List<E> selectList(String statement, Object parameter) { reset(); return super.selectList(statement, parameter); }
@Override protected void before() { db.start(); db.truncateTables(); initDbClient(); if (!disableDefaultOrganization) { insertDefaultOrganization(); } started = true; }
public DbSession getSession() { if (session == null) { session = db.getMyBatis().openSession(false); } return session; }
@Override public List<BatchResult> flushStatements() { List<BatchResult> batchResults = super.flushStatements(); reset(); return batchResults; }
/** * Returns the number of rows in the table. Example: * <pre>int issues = countRowsOfTable("issues")</pre> */ public int countRowsOfTable(String tableName) { return countRowsOfTable(tableName, new NewConnectionSupplier()); }
private DelegatingDbSessionSupplier buildRegularDbSessionSupplier() { return new DelegatingDbSessionSupplier(() -> { DbSession res = myBatis.openSession(false); ensureAutoCommitFalse(res); return res; }); }
@Override public <E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds) { reset(); return super.selectList(statement, parameter, rowBounds); }