Ploymorphic queries
DBFlow Version: develop-SNAPSHOT Issue Kind (Bug, Question, Feature): Question
Hello, I was wondering if DBFlow can do polymorphic queries?
Like I have an (abstract) class A and a subclass B. Is there a way when I query SQLite.select().from(A.class).queryList(); that I also check all of B?
At the moment my classes look like this: ` @Table(database = AppDatabase.class) public class A extends BaseModel {
@PrimaryKey(autoincrement = true)
long id;
public Long getId() { return this.id; }
} `
` @Table(database = AppDatabase.class) public class B extends A {
@ForeignKey(tableClass = A.class, saveForeignKeyModel = true)
long id;
} `
But saveForeignKeyModel does not create an object of A if I create an object of b?
` B b = new B(); b.save();
List<A> abc = SQLite.select().from(A.class).queryList();
Log.d("Len a: ", String.valueOf(abc.size())); //This returns 0
`
Thank you
No, this is not supported for SQLite. DBflow does not provide this functionality. You need to save an object of type A and B at same time if you intend for a save on B to also work on A.