objectbox-java
objectbox-java copied to clipboard
Support query filter for ID and property query
Hi,
I open this issue because I need to work with filters but whatever I do apart from QueryBuilder.filter().find() ignores the filter I made.
for example I need an array of ids and understand that in the case of QueryBuilder.filter().findIds() the definition explicitly says that the call ignores the filter, so try assigning QueryBuilder.filter().property(example_.id) .findLongs() but also in this way the filter is ignored , if I also try to do QueryBuilder.filter().count() the same
any solution other than going through the list?
Sorry, query filters are only supported for regular queries (build().find()
, also build().forEach()
). Check the source code:
https://github.com/objectbox/objectbox-java/blob/1337d56ec47303355f4d6c85630981899b713b16/objectbox-java/src/main/java/io/objectbox/query/QueryBuilder.java#L218
https://github.com/objectbox/objectbox-java/blob/1337d56ec47303355f4d6c85630981899b713b16/objectbox-java/src/main/java/io/objectbox/query/Query.java#L201
They are not used for ID queries (findIds()
) property queries (property()
) or anything else. This is because query filters work on the Java side (see above code snippet) and not on the database side.
What are you trying to do that can not be done with query conditions? -ut
Thanks for the response @greenrobot-team, i understand
My query condition is this:
box.query().filter(request -> request.getManagements().isEmpty()).build();
In my Project the Request entity has a ToMany relation with the Management entity so, i only need the ids of the request that do not have any associated management.
I also perfectly understood the point, so if there is nothing to do in this case feel free to close the issue
regards
Btw, we have plans to make filters more universal in the future.