Examples of DatabaseFieldConfig


Examples of com.j256.ormlite.field.DatabaseFieldConfig

  @Test
  public void testDaoClassGenericDao() throws Exception {
    testClass(GenericBar.class);
    DatabaseTableConfig<GenericBar> tableConfig =
        new DatabaseTableConfig<GenericBar>(GenericBar.class, Arrays.asList(new DatabaseFieldConfig("foo",
            null, DataType.UNKNOWN, null, 0, false, false, false, null, false, null, false, null, false,
            null, false, null, null, false, 0, 0)));
    testTable(tableConfig);
  }
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  @Test
  public void testDaoClassGenericDaoWithId() throws Exception {
    testClass(GenericBaz.class);
    DatabaseTableConfig<GenericBaz> tableConfig =
        new DatabaseTableConfig<GenericBaz>(GenericBaz.class, Arrays.asList(new DatabaseFieldConfig("foo",
            null, DataType.UNKNOWN, null, 0, false, false, false, null, false, null, false, null, false,
            null, false, null, null, false, 0, 0)));
    testTable(tableConfig);
  }
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  }

  @Test
  public void testFieldConfigConstructor() throws SQLException {
    List<DatabaseFieldConfig> fieldConfigs = new ArrayList<DatabaseFieldConfig>();
    fieldConfigs.add(new DatabaseFieldConfig("stuff", null, DataType.UNKNOWN, "", 0, true, false, false, null,
        false, null, false, null, false, null, false, null, null, false, 0, 0));
    DatabaseTableConfig<DatabaseTableAnno> dbTableConf =
        new DatabaseTableConfig<DatabaseTableAnno>(DatabaseTableAnno.class, fieldConfigs);
    assertEquals(DatabaseTableAnno.class, dbTableConf.getDataClass());
    assertEquals(TABLE_NAME, dbTableConf.getTableName());
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  public void testSetFieldConfigs() throws SQLException {
    DatabaseTableConfig<DatabaseTableAnno> dbTableConf = new DatabaseTableConfig<DatabaseTableAnno>();
    dbTableConf.setDataClass(DatabaseTableAnno.class);
    dbTableConf.setTableName(TABLE_NAME);
    List<DatabaseFieldConfig> fieldConfigs = new ArrayList<DatabaseFieldConfig>();
    fieldConfigs.add(new DatabaseFieldConfig("stuff", null, DataType.UNKNOWN, "", 0, true, false, false, null,
        false, null, false, null, false, null, false, null, null, false, 0, 0));
    dbTableConf.setFieldConfigs(fieldConfigs);
    dbTableConf.initialize();
    assertEquals(DatabaseTableAnno.class, dbTableConf.getDataClass());
    assertEquals(TABLE_NAME, dbTableConf.getTableName());
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  public void testSetFieldConfigsNoMatchingField() throws SQLException {
    DatabaseTableConfig<DatabaseTableAnno> dbTableConf = new DatabaseTableConfig<DatabaseTableAnno>();
    dbTableConf.setDataClass(DatabaseTableAnno.class);
    dbTableConf.setTableName(TABLE_NAME);
    List<DatabaseFieldConfig> fieldConfigs = new ArrayList<DatabaseFieldConfig>();
    fieldConfigs.add(new DatabaseFieldConfig("notstuff", null, DataType.UNKNOWN, "", 0, true, false, false, null,
        false, null, false, null, false, null, false, null, null, false, 0, 0));
    dbTableConf.setFieldConfigs(fieldConfigs);
    dbTableConf.initialize();
    assertEquals(DatabaseTableAnno.class, dbTableConf.getDataClass());
    assertEquals(TABLE_NAME, dbTableConf.getTableName());
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  }

  @Test
  public void testBaseClassHandlingWithoutAnno() throws Exception {
    List<DatabaseFieldConfig> fieldConfigs = new ArrayList<DatabaseFieldConfig>();
    DatabaseFieldConfig fieldId = new DatabaseFieldConfig("id");
    fieldId.setId(true);
    fieldConfigs.add(fieldId);
    fieldConfigs.add(new DatabaseFieldConfig("stuff"));

    DatabaseTableConfig<SubWithoutAnno> dbTableConf =
        new DatabaseTableConfig<SubWithoutAnno>(SubWithoutAnno.class, fieldConfigs);
    dbTableConf.extractFieldTypes(connectionSource);
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  }

  @Test
  public void testSetTableNameCase() throws Exception {
    List<DatabaseFieldConfig> fieldConfigs = new ArrayList<DatabaseFieldConfig>();
    DatabaseFieldConfig fieldId = new DatabaseFieldConfig("id");
    fieldId.setId(true);
    fieldConfigs.add(fieldId);
    fieldConfigs.add(new DatabaseFieldConfig("stuff"));

    DatabaseTableConfig<SubWithoutAnno> tableConfig = new DatabaseTableConfig<SubWithoutAnno>();
    tableConfig.setDataClass(SubWithoutAnno.class);
    String tableName = "mixEDcaSE";
    tableConfig.setTableName(tableName);
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  @Test
  public void testConversions() throws Exception {
    Field[] fields = Javax.class.getDeclaredFields();
    for (Field field : fields) {
      DatabaseFieldConfig config = new JavaxPersistenceImpl().createFieldConfig(databaseType, field);
      if (field.getName().equals("generatedId")) {
        assertFalse(config.isId());
        assertTrue(config.isGeneratedId());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertEquals(field.getName(), config.getFieldName());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("id")) {
        assertTrue(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertEquals(field.getName(), config.getFieldName());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("stuff")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertEquals(field.getName(), config.getFieldName());
        assertEquals(STUFF_FIELD_NAME, config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("unknown")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getDataPersister());
        assertEquals(field.getName(), config.getFieldName());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("foreignManyToOne")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertTrue(config.isForeign());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getDataPersister());
        assertEquals(field.getName(), config.getFieldName());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("foreignOneToOne")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertTrue(config.isForeign());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getDataPersister());
        assertEquals(field.getName(), config.getFieldName());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("joinFieldName")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertTrue(config.isForeign());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getDataPersister());
        assertEquals(field.getName(), config.getFieldName());
        assertEquals(JOIN_FIELD_NAME, config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("columnDefinition")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertFalse(config.isUnique());
        assertFalse(config.isVersion());
        assertTrue(config.isCanBeNull());
        assertEquals(COLUMN_DEFINITION, config.getColumnDefinition());
      } else if (field.getName().equals("uniqueColumn")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertTrue(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("nullableColumn")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertFalse(config.isUnique());
        assertFalse(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("uniqueJoinColumn")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertTrue(config.isForeign());
        assertTrue(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("nullableJoinColumn")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertTrue(config.isForeign());
        assertFalse(config.isUnique());
        assertFalse(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("ourEnumOrdinal")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertFalse(config.isUnique());
        assertFalse(config.isVersion());
        assertTrue(config.isCanBeNull());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
        assertTrue(config.getDataPersister() instanceof EnumIntegerType);
      } else if (field.getName().equals("ourEnumString")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertFalse(config.isUnique());
        assertFalse(config.isVersion());
        assertTrue(config.isCanBeNull());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
        assertTrue(config.getDataPersister() instanceof EnumStringType);
      } else if (field.getName().equals("version")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertTrue(config.isVersion());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("basic")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertFalse(config.isUnique());
        assertTrue(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else if (field.getName().equals("basicNotOptional")) {
        assertFalse(config.isId());
        assertFalse(config.isGeneratedId());
        assertFalse(config.isForeign());
        assertFalse(config.isUnique());
        assertFalse(config.isCanBeNull());
        assertFalse(config.isVersion());
        assertNull(config.getColumnName());
        assertNull(config.getColumnDefinition());
      } else {
        System.err.println("\n\n\nUnknown field: " + field.getName());
      }
    }
  }
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  @Test
  public void testCreateClass() throws Exception {
    testClass(Foo.class);
    DatabaseTableConfig<Foo> tableConfig =
        new DatabaseTableConfig<Foo>(Foo.class, Arrays.asList(new DatabaseFieldConfig("id", null,
            DataType.UNKNOWN, null, 0, false, false, false, null, false, null, false, null, false, null,
            false, null, null, false, DatabaseFieldConfig.NO_MAX_FOREIGN_AUTO_REFRESH_LEVEL_SPECIFIED, 0)));
    testTable(tableConfig);
  }
View Full Code Here

Examples of com.j256.ormlite.field.DatabaseFieldConfig

  }

  @Test
  public void testRegisterDaoTable() throws Exception {
    DatabaseTableConfig<Bar> tableConfig =
        new DatabaseTableConfig<Bar>(Bar.class, Arrays.asList(new DatabaseFieldConfig("foo", null,
            DataType.UNKNOWN, null, 0, false, false, false, null, false, null, false, null, false, null,
            false, null, null, false, DatabaseFieldConfig.NO_MAX_FOREIGN_AUTO_REFRESH_LEVEL_SPECIFIED, 0)));
    Dao<Bar, Void> dao = DaoManager.lookupDao(connectionSource, tableConfig);
    assertNull(dao);
    Dao<? extends Bar, Object> daoImpl = BaseDaoImpl.createDao(connectionSource, tableConfig);
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.