Package com.j256.ormlite.field

Examples of com.j256.ormlite.field.FieldType$LevelCounters


    if (value == null) {
      return null;
    } else if (fieldType == null) {
      return value;
    } else if (fieldType.isForeign() && fieldType.getFieldType() == value.getClass()) {
      FieldType idFieldType = fieldType.getForeignIdField();
      return idFieldType.extractJavaFieldValue(value);
    } else {
      return fieldType.convertJavaFieldToSqlArgValue(value);
    }
  }
View Full Code Here


    return true;
  }

  public ID extractId(T data) throws SQLException {
    checkForInitialized();
    FieldType idField = tableInfo.getIdField();
    @SuppressWarnings("unchecked")
    ID id = (ID) idField.extractJavaFieldValue(data);
    return id;
  }
View Full Code Here

    } else if (fieldType.isForeign() && fieldType.getFieldType() == argOrValue.getClass()) {
      /*
       * If we have a foreign field and our argument is an instance of the foreign object (i.e. not its id), then
       * we need to extract the id.
       */
      FieldType idFieldType = fieldType.getForeignIdField();
      appendArgOrValue(databaseType, idFieldType, sb, argList, idFieldType.extractJavaFieldValue(argOrValue));
      // no need for the space since it was done in the recursion
      appendSpace = false;
    } else if (fieldType.isEscapedValue()) {
      databaseType.appendEscapedWord(sb, fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString());
    } else {
View Full Code Here

  @Test
  public void testToString() throws Exception {
    Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null);
    assertTrue(where.toString().contains("empty where clause"));
    String value = "bar";
    FieldType numberFieldType =
        FieldType.createFieldType(connectionSource, "foo", Foo.class.getDeclaredField(Foo.VAL_COLUMN_NAME),
            Foo.class);
    SimpleComparison eq =
        new SimpleComparison(Foo.VAL_COLUMN_NAME, numberFieldType, value, SimpleComparison.EQUAL_TO_OPERATION);
    where.eq(Foo.VAL_COLUMN_NAME, value);
View Full Code Here

  }

  @Test
  public void testFindForeign() throws Exception {
    Dao<Foreign, String> dao = createDao(Foreign.class, false);
    FieldType fieldType = dao.findForeignFieldType(Foo.class);
    assertNotNull(fieldType);
    assertEquals("foo", fieldType.getFieldName());

    // this should be none
    fieldType = dao.findForeignFieldType(Foreign.class);
    assertNull(fieldType);
  }
View Full Code Here

    assertFalse(databaseType.isLimitAfterSelect());
  }

  @Test
  public void testBooleanConverterJavaToArg() throws Exception {
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, "foo", ManyFields.class.getDeclaredField("bool"),
            ManyFields.class);
    assertEquals(new Byte((byte) 1), booleanFieldConverter.javaToSqlArg(fieldType, Boolean.TRUE));
    assertEquals(new Byte((byte) 0), booleanFieldConverter.javaToSqlArg(fieldType, Boolean.FALSE));
  }
View Full Code Here

    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));
    assertEquals(second, booleanFieldConverter.resultToJava(fieldType, results, 2));
    verify(results);
View Full Code Here

    verify(results);
  }

  @Test
  public void testBooleanConverterParseDefaultString() throws Exception {
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, "foo", ManyFields.class.getDeclaredField("bool"),
            ManyFields.class);
    assertEquals(new Byte((byte) 1), booleanFieldConverter.parseDefaultString(fieldType, Boolean.TRUE.toString()));
    assertEquals(new Byte((byte) 0), booleanFieldConverter.parseDefaultString(fieldType, Boolean.FALSE.toString()));
  }
View Full Code Here

    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> stmtsBefore = new ArrayList<String>();
    List<String> stmtsAfter = new ArrayList<String>();
    List<String> queriesAfter = new ArrayList<String>();
    FieldType fieldType =
        FieldType.createFieldType(connectionSource, "foo", ManyFields.class.getDeclaredField(fieldName),
            ManyFields.class);
    databaseType.appendColumnArg(sb, fieldType, additionalArgs, stmtsBefore, stmtsAfter, queriesAfter);
    StringBuilder expectedSb = new StringBuilder();
    databaseType.appendEscapedEntityName(expectedSb, fieldName);
View Full Code Here

public class BaseSqliteDatabaseTypeTest extends BaseCoreTest {

  @Test(expected = IllegalArgumentException.class)
  public void testConfigureGeneratedIdNotInteger() throws Exception {
    Field field = Foo.class.getField("id");
    FieldType fieldType = FieldType.createFieldType(connectionSource, "foo", field, Foo.class);
    OurSqliteDatabaseType dbType = new OurSqliteDatabaseType();
    StringBuilder sb = new StringBuilder();
    dbType.configureGeneratedId(sb, fieldType, new ArrayList<String>(), new ArrayList<String>(),
        new ArrayList<String>());
  }
View Full Code Here

TOP

Related Classes of com.j256.ormlite.field.FieldType$LevelCounters

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.