Package com.j256.ormlite.field

Examples of com.j256.ormlite.field.FieldType


  @Test
  public void testGneratedIdLong() throws Exception {
    TableInfo<GeneratedIdLong, Long> tableInfo =
        new TableInfo<GeneratedIdLong, Long>(connectionSource, null, GeneratedIdLong.class);
    assertEquals(2, tableInfo.getFieldTypes().length);
    FieldType idField = tableInfo.getFieldTypes()[0];
    assertEquals("genId", idField.getColumnName());
    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> statementsBefore = new ArrayList<String>();
    databaseType.appendColumnArg(null, sb, idField, additionalArgs, statementsBefore, null, null);
    assertEquals(1, statementsBefore.size());
View Full Code Here


  @Test
  public void testBoolean() throws Exception {
    TableInfo<AllTypes, Integer> tableInfo =
        new TableInfo<AllTypes, Integer>(connectionSource, null, AllTypes.class);
    assertEquals(9, tableInfo.getFieldTypes().length);
    FieldType booleanField = tableInfo.getFieldTypes()[1];
    assertEquals("booleanField", booleanField.getColumnName());
    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> statementsBefore = new ArrayList<String>();
    databaseType.appendColumnArg(null, sb, booleanField, additionalArgs, statementsBefore, null, null);
    assertTrue(sb.toString() + " not in right format", sb.toString().contains("SMALLINT"));
View Full Code Here

  @Test
  public void testByte() throws Exception {
    TableInfo<AllTypes, Integer> tableInfo =
        new TableInfo<AllTypes, Integer>(connectionSource, null, AllTypes.class);
    assertEquals(9, tableInfo.getFieldTypes().length);
    FieldType byteField = tableInfo.getFieldTypes()[3];
    assertEquals("byteField", byteField.getColumnName());
    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> statementsBefore = new ArrayList<String>();
    databaseType.appendColumnArg(null, sb, byteField, additionalArgs, statementsBefore, null, null);
    assertTrue(sb.toString().contains("SMALLINT"));
View Full Code Here

    expect(mockDb.getFieldConverter(isA(DataPersister.class), isA(FieldType.class))).andReturn(dataPersister);
    expect(mockDb.isEntityNamesMustBeUpCase()).andReturn(false);
    replay(mockDb);
    connectionSource.setDatabaseType(mockDb);
    try {
      FieldType fieldType = FieldType.createFieldType(connectionSource, "foo", field, GeneratedId.class);
      verify(mockDb);
      StringBuilder sb = new StringBuilder();
      List<String> statementsBefore = new ArrayList<String>();
      databaseType.appendColumnArg(null, sb, fieldType, null, statementsBefore, null, null);
    } finally {
View Full Code Here

  }

  @Test
  public void testDropSequence() throws Exception {
    Field field = GeneratedId.class.getField("id");
    FieldType fieldType = FieldType.createFieldType(connectionSource, "foo", field, GeneratedId.class);
    List<String> statementsBefore = new ArrayList<String>();
    List<String> statementsAfter = new ArrayList<String>();
    databaseType.dropColumnArg(fieldType, statementsBefore, statementsAfter);
    assertEquals(0, statementsBefore.size());
    assertEquals(1, statementsAfter.size());
View Full Code Here

  public void testGeneratedIdSequenceAutoName() throws Exception {
    TableInfo<GeneratedIdSequenceAutoName, Integer> tableInfo =
        new TableInfo<GeneratedIdSequenceAutoName, Integer>(connectionSource, null,
            GeneratedIdSequenceAutoName.class);
    assertEquals(2, tableInfo.getFieldTypes().length);
    FieldType idField = tableInfo.getFieldTypes()[0];
    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> statementsBefore = new ArrayList<String>();
    databaseType.appendColumnArg(null, sb, idField, additionalArgs, statementsBefore, null, null);
    assertEquals(1, statementsBefore.size());
View Full Code Here

  @Test
  public void testByte() throws Exception {
    TableInfo<AllTypes, Integer> tableInfo =
        new TableInfo<AllTypes, Integer>(connectionSource, null, AllTypes.class);
    assertEquals(9, tableInfo.getFieldTypes().length);
    FieldType byteField = tableInfo.getFieldTypes()[3];
    assertEquals("byteField", byteField.getColumnName());
    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> statementsBefore = new ArrayList<String>();
    databaseType.appendColumnArg(null, sb, byteField, additionalArgs, statementsBefore, null, null);
    assertTrue(sb.toString().contains("SMALLINT"));
View Full Code Here

  @Test
  public void testLong() throws Exception {
    TableInfo<AllTypes, Integer> tableInfo =
        new TableInfo<AllTypes, Integer>(connectionSource, null, AllTypes.class);
    assertEquals(9, tableInfo.getFieldTypes().length);
    FieldType booleanField = tableInfo.getFieldTypes()[6];
    assertEquals("longField", booleanField.getColumnName());
    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> statementsBefore = new ArrayList<String>();
    databaseType.appendColumnArg(null, sb, booleanField, additionalArgs, statementsBefore, null, null);
    assertTrue(sb.toString().contains("NUMERIC"));
View Full Code Here

      return;
    }
    TableInfo<AllTypes, Integer> tableInfo =
        new TableInfo<AllTypes, Integer>(connectionSource, null, AllTypes.class);
    assertEquals(9, tableInfo.getFieldTypes().length);
    FieldType booleanField = tableInfo.getFieldTypes()[1];
    assertEquals("booleanField", booleanField.getColumnName());
    StringBuilder sb = new StringBuilder();
    List<String> additionalArgs = new ArrayList<String>();
    List<String> statementsBefore = new ArrayList<String>();
    databaseType.appendColumnArg(null, sb, booleanField, additionalArgs, statementsBefore, null, null);
    assertTrue(sb.toString().contains("TINYINT(1)"));
View Full Code Here

   * <b>NOTE:</b> I couldn't remove the code warning associated with this method when used with more than 2 arguments.
   * </p>
   */
  public Where<T, ID> and(Where<T, ID> first, Where<T, ID> second, Where<T, ID>... others) {
    Clause[] clauses = buildClauseArray(others, "AND");
    Clause secondClause = pop("AND");
    Clause firstClause = pop("AND");
    addClause(new ManyClause(firstClause, secondClause, clauses, ManyClause.AND_OPERATION));
    return this;
  }
View Full Code Here

TOP

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

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.