Package com.j256.ormlite.support

Examples of com.j256.ormlite.support.DatabaseConnection


  }

  @Test
  public void testCallBatchTasksAutoCommitTrueThrow() throws Exception {
    TableInfo<Foo, String> tableInfo = new TableInfo<Foo, String>(connectionSource, null, Foo.class);
    DatabaseConnection connection = createMock(DatabaseConnection.class);
    expect(connection.isAutoCommitSupported()).andReturn(true);
    expect(connection.getAutoCommit()).andReturn(true);
    connection.setAutoCommit(false);
    connection.setAutoCommit(true);
    StatementExecutor<Foo, String> statementExec =
        new StatementExecutor<Foo, String>(databaseType, tableInfo, null);
    replay(connection);
    try {
      statementExec.callBatchTasks(connection, false, new Callable<Void>() {
View Full Code Here


    foo.id = id;
    int equal = 21313;
    foo.equal = equal;
    assertEquals(1, dao.create(foo));

    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      dao.queryForId(id);
    } finally {
      connectionSource.releaseConnection(conn);
    }
  }
View Full Code Here

  public void testUpdateThrow() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    foo.id = "stuff";
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      assertEquals(1, dao.update(foo));
    } finally {
      connectionSource.releaseConnection(conn);
    }
  }
View Full Code Here

  public void testUpdateIdThrow() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    foo.id = "stuff";
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      assertEquals(1, dao.updateId(foo, "new id"));
    } finally {
      connectionSource.releaseConnection(conn);
    }
  }
View Full Code Here

  public void testUpdatePreparedThrow() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    foo.id = "stuff";
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      UpdateBuilder<Foo, String> ub = dao.updateBuilder();
      ub.updateColumnValue(Foo.EQUAL_COLUMN_NAME, 1);
      assertEquals(1, dao.update(ub.prepare()));
    } finally {
      connectionSource.releaseConnection(conn);
View Full Code Here

  public void testDeleteThrow() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    foo.id = "stuff";
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      dao.delete(foo);
    } finally {
      connectionSource.releaseConnection(conn);
    }
  }
View Full Code Here

  public void testDeleteCollectionThrow() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    foo.id = "stuff";
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      List<Foo> foos = new ArrayList<Foo>();
      foos.add(foo);
      dao.delete(foos);
    } finally {
      connectionSource.releaseConnection(conn);
View Full Code Here

  public void testDeleteIdsThrow() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    foo.id = "stuff";
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      List<String> foos = new ArrayList<String>();
      foos.add(foo.id);
      dao.deleteIds(foos);
    } finally {
      connectionSource.releaseConnection(conn);
View Full Code Here

    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    String id = "stuff";
    foo.id = id;
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      dao.delete(dao.deleteBuilder().prepare());
    } finally {
      connectionSource.releaseConnection(conn);
    }
  }
View Full Code Here

  public void testRefreshThrow() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    Foo foo = new Foo();
    foo.id = "stuff";
    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      conn.close();
      dao.refresh(foo);
    } finally {
      connectionSource.releaseConnection(conn);
    }
  }
View Full Code Here

TOP

Related Classes of com.j256.ormlite.support.DatabaseConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.