Bug or Feature Request:
Bug I suppose, or missed feature.
Description:
Hello, I found an exception:
java.lang.IllegalStateException: getDatabase called recursively. It happens while Migration.
The reason of it my data structure I believe:
`
class EntityA {
@PrimaryKey()
@Column
private long uid;
class EntityB {
@PrimaryKey(autoincrement = true)
private long uid;
@Column
private long entityAUid;
@Column
private String name;
}
`
And migration:
`
class Migration extends BaseMigration {
...
@Override
public void migrate(DatabaseWrapper database) {
EntityA *entityA = SQLite.select()
.from(EntityA.class)
.where(EntityA.uid.eq(%UID%))
.querySingle(database);
}
}
`
Crash happens when Model_Adapter is trying to load the EntityA from cursor because in this method: public List<EntityB> getSubentities() {..} app is trying to create a new DatabaseWrapper instance, because it want to continue getSubentities() transaction, but database is in initializing state and an exception appears.
I did not find the way how to set the right DatabaseWrapper instance in this method.
The only hotfix what I am seeing now is using:
@OneToMany(methods = {OneToMany.Method.SAVE} or anything else except
@OneToMany(methods = {OneToMany.Method.LOAD} or @OneToMany(methods = {OneToMany.Method.ALL}to avoid loading from cursor;
Please advise what I am doing wrong and help me to figure it out.
DBFlow Version: 3.1.1
Bug or Feature Request: Bug I suppose, or missed feature.
Description:
Hello, I found an exception: java.lang.IllegalStateException: getDatabase called recursively. It happens while Migration. The reason of it my data structure I believe:
` class EntityA { @PrimaryKey() @Column private long uid;
}
class EntityB { @PrimaryKey(autoincrement = true) private long uid;
} `
And migration: ` class Migration extends BaseMigration { ... @Override public void migrate(DatabaseWrapper database) { EntityA *entityA = SQLite.select() .from(EntityA.class) .where(EntityA.uid.eq(%UID%)) .querySingle(database);
} `
Crash happens when Model_Adapter is trying to load the EntityA from cursor because in this method:
public List<EntityB> getSubentities() {..}
app is trying to create a new DatabaseWrapper instance, because it want to continue getSubentities() transaction, but database is in initializing state and an exception appears.I did not find the way how to set the right DatabaseWrapper instance in this method. The only hotfix what I am seeing now is using:
@OneToMany(methods = {OneToMany.Method.SAVE}
or anything else except@OneToMany(methods = {OneToMany.Method.LOAD}
or@OneToMany(methods = {OneToMany.Method.ALL}
to avoid loading from cursor;Please advise what I am doing wrong and help me to figure it out.
Read your docs: https://agrosner.gitbooks.io/dbflow/content/Relationships.html https://agrosner.gitbooks.io/dbflow/content/Migrations.html
But it did not help me. Maybe this issue is fixed in newest version. But I would like to continue using a 3+ version. Thanks.
My apologize for code formatting, did not find the way how to make it better.