DBFlow v4.1.0 Release Notes

Release Date: 2017-08-27 // over 3 years ago
  • โœ… 1. @ModelView are now created after migrations are run so latest DB data is respected.

    1. New annotation @ColumnMap! It enables embedding other object's exposed properties into the current table as @Column so that object hierarchy is respected without excessive DB complication.

      class Location(var latitude: Double = 0.0, var longitude: Double = 0.0)@Table(database = TestDatabase::class)class Position(@PrimaryKey var id: Int = 0, @ColumnMap var location: Location? = null)

    creates a table with the following columns:

      public static final Property<Integer> id = new Property<Integer>(Position.class, "id");
      public static final Property<Double> latitude = new Property<Double>(Position.class, "latitude");
      public static final Property<Double> longitude = new Property<Double>(Position.class, "longitude");
    
    1. @database(name = , extension = ) are deprecated. Specify the name now in the DatabaseConfig.databaseName() when FlowManager is initialized. This means that DBFlow supports dynamic database names and instances.

      FlowManager.init(FlowConfig.builder() .addDatabaseConfig(DatabaseConfig.builder(AppDatabase.class) .databaseName("AppDatabase") .databaseExtension(".txt") .build()) .build())

    To dynamically swap database out, replace the FlowConfig:

    FlowManager.getDatabase(AppDatabase.class) .reset(DatabaseConfig.builder(AppDatabase.class) .databaseName("AppDatabase-2") .build())
    

    โœ‚ Note that this will overwrite all existing database properties for a database. Any TableConfig properties missing will get ignored. Also it will delete existing db and reopen with new instance specified.

    1. @database(inMemory = ) is deprecated. Use the new builder method:

      FlowManager.init(FlowConfig.builder() .addDatabaseConfig(DatabaseConfig.inMemoryBuilder(AppDatabase.class) .databaseName("AppDatabase") .build()) .build())

    ๐Ÿ‘ 1. Support javax.annotation.Generated if it's on the classpath.

    1. @database(generatedClassSeparator = ) is now deprecated. It will be standardized to the default _ in a future breaking release. ๐Ÿ—„ 3. @OneToMany now auto-detect visibility of the reference field so isVariablePrivate() is deprecated.
    2. Can specify @ForeignKeyReference(notNull = @NotNull()) annotation for individual references. Required to specify all references on a @ForeignKey if you need to specify for one. ๐Ÿ‘ 5. Some better error messaging in the annotation processor so its easier to find solutions to common issues. ๐Ÿ—„ 6. Rename count() (deprecated) to longValue() so its more clear exactly what is happening.
    3. fix #1401 which enables custom TypeConverters to carry into an as() alias of a Property.
    4. Add new TransactionWrapper which allows grouping of ITransaction into one to get executed at same point in db time. ๐Ÿ— 9. Lib now compiles with SDK 26 with latest build tools including api/implementation of 3.0.0+ gradle plugin. โšก๏ธ 10. RXJava2 is now updated to 2.1.3 โšก๏ธ 11. Update some methods of dbflow-kotlin-extensions to accept nullable values for objects where it makes sense. See commit
    5. Automatic creation of tables can be turned off on a table-by-table basis with createWithDatabase(). Useful for preserving scrapped table in previous migrations.
    6. Using Kotlin we can drastically reduce the @OneToMany code implementation:

      @OneToMany(methods = {OneToMany.Method.ALL}, variableName = "ants") public List<Ant> getMyAnts() { if (ants == null || ants.isEmpty()) { ants = SQLite.select() .from(Ant.class) .where(Ant_Table.queen_id.eq(id)) .queryList(); } return ants; }

    to:

    @get:OneToMany(methods = arrayOf(OneToMany.Method.ALL))var ants by oneToMany { select from Ant::class where (Ant\_Table.queen\_id.eq(id)) }