Skip to content

4.1.0

Compare
Choose a tag to compare
@agrosner agrosner released this 27 Aug 23:13
· 547 commits to master since this release
  1. @ModelView are now created after migrations are run so latest DB data is respected.
  2. 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.
  2. @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.
  4. 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.
  7. fix #1401 which enables custom TypeConverters to carry into an as() alias of a Property.
  8. 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
  12. Automatic creation of tables can be turned off on a table-by-table basis with createWithDatabase(). Useful for preserving scrapped table in previous migrations.
  13. 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)) }