Description
Spring data version: 3.3.0-M2
I use "_id" field as a string type and I want to use this field with $in operator like this.
@Override
public List<T> findAllById(Iterable<String> ids)
{
final Query query = new Query();
query.addCriteria(Criteria.where("_id").in(ids));
return template.find(query, type);
}
But console output is like this:
find using query: { "_id" : "{\"$in\" : [\"5b8bedceb1e0bfc07b008828\", \"5b8bedceb1e0bfc07b008829\", \"5b8bedceb1e0bfc07b00882a\"]}"} fields: Document{{}} for class:
But $in operator running properly with other fields.
public List<RolePrivilege> findPermissions(String tenantId, List<String> roles)
{
final Query query = new Query(Criteria.where("tenantId").is(tenantId));
if (CollectionUtil.isNotEmpty(roles))
{
query.addCriteria(Criteria.where("roleId").in(roles));
}
query.addCriteria(notDeletedItemsCriteria);
return template.find(query, RolePrivilege.class);
}
find using query: { "tenantId" : "5b8bedceb1e0bfc07b00882f", "roleId" : { "$in" : ["5b8bedceb1e0bfc07b008828", "5b8bedceb1e0bfc07b008829", "5b8bedceb1e0bfc07b00882a", "5b8bedceb1e0bfc07b00882e", "5c6f3b1f1c36570fc572765c", "5eb8b5f540e3006cfa56de26"]}, "deleted" : false} fields: Document{{}} for class
On execution time the criteria api adding backslash "\" to the query and don't return any data.