Examples of queryForLong()


Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

    TableInfo<GeneratedId, Integer> tableInfo =
        new TableInfo<GeneratedId, Integer>(connectionSource, null, GeneratedId.class);
    StatementExecutor<GeneratedId, Integer> se =
        new StatementExecutor<GeneratedId, Integer>(databaseType, tableInfo, null);
    DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
    expect(databaseConnection.queryForLong(isA(String.class))).andReturn(1L);
    expect(databaseConnection.insert(isA(String.class), isA(Object[].class), isA(FieldType[].class))).andReturn(1);

    replay(databaseConnection);
    GeneratedId genIdSeq = new GeneratedId();
    se.create(databaseConnection, genIdSeq);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

    connectionSource.setDatabaseType(databaseType);
    StatementExecutor<GeneratedIdLong, Long> se =
        new StatementExecutor<GeneratedIdLong, Long>(databaseType, new TableInfo<GeneratedIdLong, Long>(
            connectionSource, null, GeneratedIdLong.class), null);
    DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
    expect(databaseConnection.queryForLong(isA(String.class))).andReturn(1L);
    expect(databaseConnection.insert(isA(String.class), isA(Object[].class), isA(FieldType[].class))).andReturn(1);

    replay(databaseConnection);
    GeneratedIdLong genIdSeq = new GeneratedIdLong();
    se.create(databaseConnection, genIdSeq);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

  }

  @Test(expected = SQLException.class)
  public void testSequenceZero() throws Exception {
    DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
    expect(databaseConnection.queryForLong(isA(String.class))).andReturn(0L);
    replay(databaseConnection);
    NeedsSequenceDatabaseType needsSequence = new NeedsSequenceDatabaseType();;
    MappedCreate<GeneratedIdSequence, Integer> mappedCreate =
        MappedCreate.build(needsSequence, new TableInfo<GeneratedIdSequence, Integer>(connectionSource, null,
            GeneratedIdSequence.class));
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

    TableInfo<GeneratedId, Integer> tableInfo =
        new TableInfo<GeneratedId, Integer>(connectionSource, null, GeneratedId.class);
    StatementExecutor<GeneratedId, Integer> se =
        new StatementExecutor<GeneratedId, Integer>(databaseType, tableInfo, null);
    DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
    expect(databaseConnection.queryForLong(isA(String.class))).andReturn(1L);
    expect(
        databaseConnection.insert(isA(String.class), isA(Object[].class), isA(FieldType[].class),
            (GeneratedKeyHolder) isNull())).andReturn(1);

    replay(databaseConnection);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

    connectionSource.setDatabaseType(databaseType);
    StatementExecutor<GeneratedIdLong, Long> se =
        new StatementExecutor<GeneratedIdLong, Long>(databaseType, new TableInfo<GeneratedIdLong, Long>(
            connectionSource, null, GeneratedIdLong.class), null);
    DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
    expect(databaseConnection.queryForLong(isA(String.class))).andReturn(1L);
    expect(
        databaseConnection.insert(isA(String.class), isA(Object[].class), isA(FieldType[].class),
            (GeneratedKeyHolder) isNull())).andReturn(1);

    replay(databaseConnection);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

  }

  @Test(expected = SQLException.class)
  public void testSequenceZero() throws Exception {
    DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
    expect(databaseConnection.queryForLong(isA(String.class))).andReturn(0L);
    replay(databaseConnection);
    NeedsSequenceDatabaseType needsSequence = new NeedsSequenceDatabaseType();;
    MappedCreate<GeneratedIdSequence, Integer> mappedCreate =
        MappedCreate.build(needsSequence, new TableInfo<GeneratedIdSequence, Integer>(connectionSource, null,
            GeneratedIdSequence.class));
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

      Dao<Foo, Object> dao = createDao(Foo.class, true);
      Foo foo = new Foo();
      long id = 21321321L;
      foo.id = id;
      assertEquals(1, dao.create(foo));
      assertEquals(id, databaseConnection.queryForLong("select id from foo"));
    } finally {
      connectionSource.releaseConnection(databaseConnection);
    }
  }
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

  @Test(expected = SQLException.class)
  public void testQueryForLongNoResult() throws Exception {
    DatabaseConnection databaseConnection = connectionSource.getReadOnlyConnection();
    try {
      createDao(Foo.class, true);
      databaseConnection.queryForLong("select id from foo");
    } finally {
      connectionSource.releaseConnection(databaseConnection);
    }
  }
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

      long id = 21321321L;
      foo.id = id;
      // insert twice
      assertEquals(1, dao.create(foo));
      assertEquals(1, dao.create(foo));
      databaseConnection.queryForLong("select id from foo");
    } finally {
      connectionSource.releaseConnection(databaseConnection);
    }
  }
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection.queryForLong()

  public void testTestConnectionThatWasClosed() throws Exception {
    JdbcPooledConnectionSource pooled = new JdbcPooledConnectionSource(DEFAULT_DATABASE_URL);
    String pingStatement = pooled.getDatabaseType().getPingStatement();
    try {
      DatabaseConnection conn1 = pooled.getReadWriteConnection();
      conn1.queryForLong(pingStatement);
      pooled.releaseConnection(conn1);
      // close it behind the pool's back, bad dog
      conn1.close();
      DatabaseConnection conn2 = pooled.getReadWriteConnection();
      assertSame(conn1, conn2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.