Tabnine Logo
DatabaseConnection.setSavePoint
Code IndexAdd Tabnine to your IDE (free)

How to use
setSavePoint
method
in
com.j256.ormlite.support.DatabaseConnection

Best Java code snippets using com.j256.ormlite.support.DatabaseConnection.setSavePoint (Showing top 15 results out of 315)

origin: stackoverflow.com

 DatabaseConnection conn = dao.startThreadConnection();
Savepoint savePoint = null;
try {
  savePoint = conn.setSavePoint(null);
  doInserts(dao);
} finally {
  // commit at the end
  conn.commit(savePoint);
  dao.endThreadConnection(conn);
}
origin: j256/ormlite-core

@Override
public Savepoint setSavePoint(String name) throws SQLException {
  if (proxy == null) {
    return null;
  } else {
    return proxy.setSavePoint(name);
  }
}
origin: com.j256.ormlite/ormlite-core

@Override
public Savepoint setSavePoint(String name) throws SQLException {
  if (proxy == null) {
    return null;
  } else {
    return proxy.setSavePoint(name);
  }
}
origin: j256/ormlite-core

@Test
public void testSetSavePoint() throws Exception {
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  String name = "savepoint";
  expect(conn.setSavePoint(name)).andReturn(null);
  conn.close();
  DatabaseConnectionProxy proxy = new DatabaseConnectionProxy(conn);
  replay(conn);
  proxy.setSavePoint(name);
  proxy.close();
  verify(conn);
}
origin: com.expanset.hk2/hk2-persistence-ormlite

/**
 * @param connectionSource {@link ConnectionSource} for transaction.
 * @throws SQLException Connection error.
 */
public OrmliteTransaction(@Nonnull ConnectionSource connectionSource) 
    throws SQLException {
  Validate.notNull(connectionSource, "connectionSource");
  
  this.connectionSource = connectionSource;	
  this.connection = this.connectionSource.getReadWriteConnection();
  
  final boolean saved = this.connectionSource.saveSpecialConnection(connection);	
  if (saved || connectionSource.getDatabaseType().isNestedSavePointsSupported()) {
    if (connection.isAutoCommitSupported()) {
      autoCommitAtStart = connection.isAutoCommit();
      if (autoCommitAtStart) {
        connection.setAutoCommit(false);
      }
    } else {
      autoCommitAtStart = false;
    }
    savepoint = connection.setSavePoint(SAVE_POINT_PREFIX + savepointCounter.incrementAndGet());
  } else {
    savepoint = null;
    autoCommitAtStart = false;
  }        
} 
 
origin: j256/ormlite-core

@Test
public void testTransactionManagerSavePointNull() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(false);
  expect(conn.setSavePoint(isA(String.class))).andReturn(null);
  conn.commit(null);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn);
  TransactionManager tm = new TransactionManager(connectionSource);
  tm.callInTransaction(new Callable<Void>() {
    @Override
    public Void call() {
      return null;
    }
  });
  verify(connectionSource, conn);
}
origin: j256/ormlite-core

@Test
public void testTransactionManagerTableName() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.commit(savePoint);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(FOO_TABLE_NAME)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  tm.callInTransaction(FOO_TABLE_NAME, new Callable<Void>() {
    @Override
    public Void call() {
      return null;
    }
  });
  verify(connectionSource, conn, savePoint);
}
origin: j256/ormlite-core

@Test
public void testTransactionManager() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.commit(savePoint);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  tm.callInTransaction(new Callable<Void>() {
    @Override
    public Void call() {
      return null;
    }
  });
  verify(connectionSource, conn, savePoint);
}
origin: j256/ormlite-core

@Test
public void testTransactionManagerAutoCommitSupported() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(true);
  expect(conn.isAutoCommit()).andReturn(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.commit(savePoint);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  tm.callInTransaction(new Callable<Void>() {
    @Override
    public Void call() {
      return null;
    }
  });
  verify(connectionSource, conn, savePoint);
}
origin: j256/ormlite-core

@Test
public void testTransactionManagerRollbackNullSavePoint() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(false);
  expect(conn.setSavePoint(isA(String.class))).andReturn(null);
  conn.rollback(null);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn);
  TransactionManager tm = new TransactionManager(connectionSource);
  try {
    tm.callInTransaction(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        throw new SQLException("you better roll back!!");
      }
    });
    fail("expected an exception");
  } catch (SQLException e) {
    // expected
  }
  verify(connectionSource, conn);
}
origin: j256/ormlite-core

@Test
public void testTransactionManagerAutoCommitOn() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(true);
  expect(conn.isAutoCommit()).andReturn(true);
  conn.setAutoCommit(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.commit(savePoint);
  conn.setAutoCommit(true);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  tm.callInTransaction(new Callable<Void>() {
    @Override
    public Void call() {
      return null;
    }
  });
  verify(connectionSource, conn, savePoint);
}
origin: j256/ormlite-core

@Test
public void testTransactionManagerRollbackOtherException() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.rollback(savePoint);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  try {
    tm.callInTransaction(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        throw new Exception("you better roll back!!");
      }
    });
    fail("expected an exception");
  } catch (Exception e) {
    // expected
  }
  verify(connectionSource, conn, savePoint);
}
origin: j256/ormlite-core

@Test
public void testTransactionManagerRollback() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.rollback(savePoint);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  try {
    tm.callInTransaction(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        throw new SQLException("you better roll back!!");
      }
    });
    fail("expected an exception");
  } catch (SQLException e) {
    // expected
  }
  verify(connectionSource, conn, savePoint);
}
origin: j256/ormlite-core

savePoint = connection.setSavePoint(SAVE_POINT_PREFIX + savePointCounter.incrementAndGet());
if (savePoint == null) {
  logger.trace("started savePoint transaction");
origin: com.j256.ormlite/ormlite-core

savePoint = connection.setSavePoint(SAVE_POINT_PREFIX + savePointCounter.incrementAndGet());
if (savePoint == null) {
  logger.trace("started savePoint transaction");
com.j256.ormlite.supportDatabaseConnectionsetSavePoint

Javadoc

Start a save point with a certain name. It can be a noop if savepoints are not supported.

Popular methods of DatabaseConnection

  • executeStatement
    Execute a statement directly on the connection.
  • isAutoCommit
    Return if auto-commit is currently enabled.
  • setAutoCommit
    Set the auto-commit to be on (true) or off (false). Setting auto-commit to true may or may-not cause
  • commit
    Commit all changes since the savepoint was created. If savePoint is null then commit all outstanding
  • compileStatement
    Like compileStatement(String, StatementType, FieldType[]) except the caller can specify the result f
  • close
  • closeQuietly
    Close the connection to the database but swallow any exceptions.
  • insert
    Perform a SQL update while with the associated SQL statement, arguments, and types. This will possib
  • isAutoCommitSupported
    Return if auto-commit is supported.
  • queryForLong
    Perform a query whose result should be a single long-integer value.
  • rollback
    Roll back all changes since the savepoint was created. If savePoint is null then roll back all outst
  • delete
    Perform a SQL delete with the associated SQL statement, arguments, and types.
  • rollback,
  • delete,
  • isClosed,
  • isTableExists,
  • queryForOne,
  • update,
  • releaseSavePoint

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • setRequestProperty (URLConnection)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now