I am trying to query my database for all models with primary keys in a list. This is my query (idsList is an ArrayList containing integers):
new Select().from(PostModel.class)
.where(Condition.column(PostModel$Table.ID).in(0, idsList))
.async().queryList(listener);
But Android Studio highlights the where condition, stating
"Cannot resolve method 'where(com.raizlabs.android.dbflow.sql.builder.Condition.In)"
So is Condition.In not considered a condition? How can I query all Models with primaryKey in an ArrayList?
I am using DBFlow 2.0. I can also use a regular SQL query String as a substitute, but I am not that versed in SQL, so if you could provide an SQL query String for my problem, that would be a possible workaround.
DBFlow v3.x
now allows you to pass a collection to Condition.in()
List<String> ids = new ArrayList<>();
Condition.In in = Condition.column(Tree_Table.ID.getNameAlias()).in(ids);
long count = new Select().count().from(Tree.class)
.where(in)
.count();
Create a In
Condition:
List<String> ids = new ArrayList<String>();
Condition.In in = Condition.column(Tree$Table.ID).in(ids.get(0));
for (i = 1; i < ids.size(); i++){
in.and(ids.get(i));
}
long count = new Select().count().from(Tree.class)
.where(in)
.count();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With