Package com.j256.ormlite.support

Examples of com.j256.ormlite.support.DatabaseResults


      throws SQLException {
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = preparedQuery.compile(conn);
      DatabaseResults results = stmt.runQuery();
      int fooC = 0;
      while (results.next()) {
        LocalFoo foo2 = preparedQuery.mapRow(results);
        assertEquals(foos.get(fooC).id, foo2.id);
        fooC++;
      }
      assertEquals(expectedNum, fooC);
View Full Code Here


    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes);
      DatabaseResults results = stmt.runQuery();
      assertTrue(results.next());
      int colNum = results.findColumn(STRING_COLUMN);
      DataType.DATE_STRING.getDataPersister().resultToJava(null, results, colNum);
    } finally {
      if (stmt != null) {
        stmt.close();
      }
View Full Code Here

    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes);
      DatabaseResults results = stmt.runQuery();
      assertTrue(results.next());
      int colNum = results.findColumn(STRING_COLUMN);
      DataType.JAVA_DATE_STRING.getDataPersister().resultToJava(null, results, colNum);
    } finally {
      if (stmt != null) {
        stmt.close();
      }
View Full Code Here

    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes);
      DatabaseResults results = stmt.runQuery();
      assertTrue(results.next());
      FieldType fieldType =
          FieldType.createFieldType(connectionSource, TABLE_NAME,
              clazz.getDeclaredField(SERIALIZABLE_COLUMN), clazz);
      assertNull(DataType.SERIALIZABLE.getDataPersister().resultToJava(fieldType, results,
          results.findColumn(SERIALIZABLE_COLUMN)));
    } finally {
      if (stmt != null) {
        stmt.close();
      }
      connectionSource.releaseConnection(conn);
View Full Code Here

    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes);
      DatabaseResults results = stmt.runQuery();
      assertTrue(results.next());
      FieldType fieldType =
          FieldType.createFieldType(connectionSource, TABLE_NAME,
              LocalSerializable.class.getDeclaredField(SERIALIZABLE_COLUMN), LocalSerializable.class);
      DataType.SERIALIZABLE.getDataPersister().resultToJava(fieldType, results, results.findColumn(BYTE_COLUMN));
    } finally {
      if (stmt != null) {
        stmt.close();
      }
      connectionSource.releaseConnection(conn);
View Full Code Here

    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes);
      DatabaseResults results = stmt.runQuery();
      assertTrue(results.next());
      assertEquals(val.toString(),
          DataType.ENUM_STRING.getDataPersister()
              .resultToJava(null, results, results.findColumn(ENUM_COLUMN)));
    } finally {
      if (stmt != null) {
        stmt.close();
      }
      connectionSource.releaseConnection(conn);
View Full Code Here

    assertEquals(1, dao.create(foo));
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes);
      DatabaseResults results = stmt.runQuery();
      assertTrue(results.next());
      assertEquals(
          val.ordinal(),
          DataType.ENUM_INTEGER.getDataPersister().resultToJava(null, results,
              results.findColumn(ENUM_COLUMN)));
    } finally {
      if (stmt != null) {
        stmt.close();
      }
      connectionSource.releaseConnection(conn);
View Full Code Here

    DataPersister dataPersister = dataType.getDataPersister();
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes);
      DatabaseResults results = stmt.runQuery();
      assertTrue(results.next());
      int colNum = results.findColumn(columnName);
      FieldType fieldType =
          FieldType.createFieldType(connectionSource, TABLE_NAME, clazz.getDeclaredField(columnName), clazz);
      if (javaVal instanceof byte[]) {
        assertTrue(Arrays.equals((byte[]) javaVal,
            (byte[]) dataPersister.resultToJava(fieldType, results, colNum)));
View Full Code Here

        new FieldType[] { FieldType.createFieldType(connectionSource, tableName, field, Foo.class) };
    BaseMappedQuery<Foo, String> baseMappedQuery =
        new BaseMappedQuery<Foo, String>(baseFooTableInfo, "select * from " + tableName, new FieldType[0],
            resultFieldTypes) {
        };
    DatabaseResults results = createMock(DatabaseResults.class);
    int colN = 1;
    expect(results.findColumn(Foo.ID_COLUMN_NAME)).andReturn(colN);
    String idString = "deopdjed";
    expect(results.getString(colN)).andReturn(idString);
    expect(results.wasNull(colN)).andReturn(false);
    replay(results);
    Foo baseFoo = baseMappedQuery.mapRow(results);
    assertNotNull(baseFoo);
    assertEquals(idString, baseFoo.id);
    verify(results);
View Full Code Here

    assertEquals(1, dao.queryForAll().size());

    @SuppressWarnings("unchecked")
    SelectIterator<Foo, String> iterator = (SelectIterator<Foo, String>) dao.iterator();
    DatabaseResults results = iterator.getRawResults();
    assertTrue(results.next());
    iterator.close();
  }
View Full Code Here

TOP

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

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.