4.1.0
@ModelView
are now created after migrations are run so latest DB data is respected.- 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");
- @database(name = , extension = ) are deprecated. Specify the name now in the
DatabaseConfig.databaseName()
whenFlowManager
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.
- @database(inMemory = ) is deprecated. Use the new builder method:
FlowManager.init(FlowConfig.builder()
.addDatabaseConfig(DatabaseConfig.inMemoryBuilder(AppDatabase.class)
.databaseName("AppDatabase")
.build())
.build())
- Support
javax.annotation.Generated
if it's on the classpath. - @database(generatedClassSeparator = ) is now deprecated. It will be standardized to the default
_
in a future breaking release. @OneToMany
now auto-detect visibility of the reference field soisVariablePrivate()
is deprecated.- Can specify
@ForeignKeyReference(notNull = @NotNull())
annotation for individual references. Required to specify allreferences
on a@ForeignKey
if you need to specify for one. - Some better error messaging in the annotation processor so its easier to find solutions to common issues.
- Rename
count()
(deprecated) tolongValue()
so its more clear exactly what is happening. - fix #1401 which enables custom
TypeConverters
to carry into anas()
alias of aProperty
. - Add new
TransactionWrapper
which allows grouping ofITransaction
into one to get executed at same point in db time. - Lib now compiles with SDK 26 with latest build tools including
api
/implementation
of 3.0.0+ gradle plugin. - RXJava2 is now updated to
2.1.3
- Update some methods of
dbflow-kotlin-extensions
to accept nullable values for objects where it makes sense. See commit - Automatic creation of tables can be turned off on a table-by-table basis with
createWithDatabase()
. Useful for preserving scrapped table in previous migrations. - 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)) }