Package com.j256.ormlite.support

Examples of com.j256.ormlite.support.DatabaseResults.findColumn()


    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 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);
View Full Code Here

            resultFieldTypes) {
        };
    DatabaseResults results = createMock(DatabaseResults.class);
    int colN = 1;
    expect(results.getObjectCache()).andReturn(null);
    expect(results.findColumn(Foo.ID_COLUMN_NAME)).andReturn(colN);
    int id = 63365;
    expect(results.getInt(colN)).andReturn(id);
    replay(results);
    Foo baseFoo = baseMappedQuery.mapRow(results);
    assertNotNull(baseFoo);
View Full Code Here

      DatabaseResults results = stmt.runQuery(null);
      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

              DatabaseConnection.DEFAULT_RESULT_FLAGS);
      DatabaseResults results = stmt.runQuery(null);
      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

      stmt =
          conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes,
              DatabaseConnection.DEFAULT_RESULT_FLAGS);
      DatabaseResults results = stmt.runQuery(null);
      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

      stmt =
          conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, noFieldTypes,
              DatabaseConnection.DEFAULT_RESULT_FLAGS);
      DatabaseResults results = stmt.runQuery(null);
      assertTrue(results.next());
      int colNum = results.findColumn(columnName);
      Field field = clazz.getDeclaredField(columnName);
      FieldType fieldType = FieldType.createFieldType(connectionSource, TABLE_NAME, field, clazz);
      Class<?>[] classes = fieldType.getDataPersister().getAssociatedClasses();
      if (classes.length > 0) {
        assertTrue(classes[0].isAssignableFrom(fieldType.getType()));
View Full Code Here

      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

      DatabaseResults results = stmt.runQuery(null);
      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

    // it can't be null
    foo.name = nameArg + " not that";
    assertEquals(nameArg, fieldType.extractJavaFieldToSqlArgValue(foo));

    DatabaseResults resultMock = createMock(DatabaseResults.class);
    expect(resultMock.findColumn("name")).andReturn(0);
    expect(resultMock.wasNull(0)).andReturn(false);
    replay(resultMock);
    assertEquals(nameResult, fieldType.resultToJava(resultMock, new HashMap<String, Integer>()));
    verify(resultMock);
    assertTrue(resultToSqlArgCalled.get());
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.