Package com.j256.ormlite.field

Examples of com.j256.ormlite.field.FieldType


  @Test
  public void testByte() throws Exception {
    TableInfo<AllTypes, Void> tableInfo = new TableInfo<AllTypes, Void>(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


      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

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

      return;
    }
    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

      return;
    }
    TableInfo<AllTypes, Integer> tableInfo =
        new TableInfo<AllTypes, Integer>(connectionSource, null, AllTypes.class);
    assertEquals(9, tableInfo.getFieldTypes().length);
    FieldType byteField = tableInfo.getFieldTypes()[2];
    assertEquals("dateField", 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("DATETIME"));
View Full Code Here

    }
    List<String> additionalArgs = new ArrayList<String>();
    List<String> moreStmts = new ArrayList<String>();
    List<String> queriesAfter = new ArrayList<String>();
    TableInfo<StringId, String> tableInfo = new TableInfo<StringId, String>(connectionSource, null, StringId.class);
    FieldType fieldType = tableInfo.getIdField();
    StringBuilder sb = new StringBuilder();
    databaseType.appendColumnArg(null, sb, fieldType, additionalArgs, null, moreStmts, queriesAfter);
    assertTrue(sb.toString().contains(fieldType.getColumnName()));
    if (!sb.toString().contains("PRIMARY KEY")) {
      databaseType.addPrimaryKeySql(new FieldType[] { fieldType }, additionalArgs, null, moreStmts, queriesAfter);
      assertEquals(1, additionalArgs.size());
      assertTrue(additionalArgs.get(0).contains("PRIMARY KEY"));
    }
View Full Code Here

    expect(mockDb.getFieldConverter(isA(DataPersister.class), isA(FieldType.class))).andReturn(dataPersister);
    expect(mockDb.isEntityNamesMustBeUpCase()).andReturn(true);
    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);
    databaseType.addPrimaryKeySql(new FieldType[] { idField }, additionalArgs, statementsBefore, null, null);
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().contains("BIT"));
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.