Examples of DatabaseResults


Examples of com.j256.ormlite.support.DatabaseResults

    LocalFoo foo = new LocalFoo();
    // 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

Examples of com.j256.ormlite.support.DatabaseResults

  public void testNullPrimitiveThrow() throws Exception {
    Field field = ThrowIfNullNonPrimitive.class.getDeclaredField("primitive");
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, ThrowIfNullNonPrimitive.class.getSimpleName(), field,
            ThrowIfNullNonPrimitive.class);
    DatabaseResults results = createMock(DatabaseResults.class);
    int fieldNum = 1;
    expect(results.findColumn(field.getName())).andReturn(fieldNum);
    expect(results.getInt(fieldNum)).andReturn(0);
    expect(results.wasNull(fieldNum)).andReturn(true);
    replay(results);
    fieldType.resultToJava(results, new HashMap<String, Integer>());
    verify(results);
  }
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseResults

    assertTrue(fields.length >= 1);
    Field field = fields[0];
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, SerializableField.class.getSimpleName(), field,
            SerializableField.class);
    DatabaseResults results = createMock(DatabaseResults.class);
    int fieldNum = 1;
    expect(results.findColumn(field.getName())).andReturn(fieldNum);
    expect(results.getTimestamp(fieldNum)).andReturn(null);
    expect(results.wasNull(fieldNum)).andReturn(true);
    replay(results);
    assertNull(fieldType.resultToJava(results, new HashMap<String, Integer>()));
    verify(results);
  }
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseResults

    Field[] fields = InvalidType.class.getDeclaredFields();
    assertTrue(fields.length >= 1);
    Field field = fields[0];
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, InvalidType.class.getSimpleName(), field, InvalidType.class);
    DatabaseResults results = createMock(DatabaseResults.class);
    int fieldNum = 1;
    expect(results.findColumn(field.getName())).andReturn(fieldNum);
    expect(results.wasNull(fieldNum)).andReturn(true);
    replay(results);
    assertNull(fieldType.resultToJava(results, new HashMap<String, Integer>()));
    verify(results);
  }
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseResults

    foreignForeign.stuff = stuff;
    expect(
        connection.queryForOne(isA(String.class), isA(Object[].class), isA(FieldType[].class),
            isA(GenericRowMapper.class), (ObjectCache) isNull())).andReturn(foreignForeign);
    connectionSource.releaseConnection(connection);
    DatabaseResults results = createMock(DatabaseResults.class);
    ForeignAutoRefresh foreign = new ForeignAutoRefresh();
    replay(results, connectionSource, connection);
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, ForeignAutoRefresh.class.getSimpleName(), field,
            ForeignAutoRefresh.class);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseResults

    try {
      stmt =
          conn.compileStatement("select * from " + TABLE_NAME, StatementType.SELECT, new FieldType[0],
              DatabaseConnection.DEFAULT_RESULT_FLAGS);

      DatabaseResults results = stmt.runQuery(null);
      while (results.next()) {
        LocalFoo foo2 = rowMapper.mapRow(results);
        assertEquals(foo1.id, foo2.id);
      }
    } finally {
      if (stmt != null) {
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseResults

      throws SQLException {
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    CompiledStatement stmt = null;
    try {
      stmt = preparedQuery.compile(conn, StatementType.SELECT);
      DatabaseResults results = stmt.runQuery(null);
      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

Examples of com.j256.ormlite.support.DatabaseResults

    assertEquals(Byte.valueOf((byte) 0), booleanFieldConverter.javaToSqlArg(fieldType, Boolean.FALSE));
  }

  @Test
  public void testBooleanConverterResultToJava() throws Exception {
    DatabaseResults results = createMock(DatabaseResults.class);
    boolean first = Boolean.TRUE;
    boolean second = Boolean.FALSE;
    expect(results.getByte(1)).andReturn((byte) 1);
    expect(results.getByte(2)).andReturn((byte) 0);
    replay(results);
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, "foo", ManyFields.class.getDeclaredField("bool"),
            ManyFields.class);
    assertEquals(first, booleanFieldConverter.resultToJava(fieldType, results, 1));
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseResults

      try {
        compiledStmt =
            connection.compileStatement(query, StatementType.SELECT, noFieldTypes,
                DatabaseConnection.DEFAULT_RESULT_FLAGS);
        // we don't care about an object cache here
        DatabaseResults results = compiledStmt.runQuery(null);
        int rowC = 0;
        // count the results
        for (boolean isThereMore = results.first(); isThereMore; isThereMore = results.next()) {
          rowC++;
        }
        logger.info("executing create table after-query got {} results: {}", rowC, query);
      } catch (SQLException e) {
        // we do this to make sure that the statement is in the exception
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseResults

    assertEquals(1, dao.create(foo));

    CloseableIterator<Foo> iterator =
        dao.iterator(dao.queryBuilder().where().eq(Foo.VAL_COLUMN_NAME, foo.val).prepare());
    try {
      DatabaseResults results = iterator.getRawResults();
      assertTrue(results.first());
      assertTrue(results.getColumnCount() >= 4);
      int valIndex = results.findColumn(Foo.VAL_COLUMN_NAME);
      assertEquals(foo.val, results.getInt(valIndex));
      assertFalse(results.next());
    } finally {
      iterator.closeQuietly();
    }
  }
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.