Reputation: 148
I want to apply multiple condition on Criteria but andOperator seconds String gives error
mongoTemplate.find(new Query(new Criteria().andOperator (Criteria.where("notificationTime").gte(DateTime.now().minusMinutes(15).millisOfSecond()) .andOperator(Criteria.where("failureCount")).gt(3))) );
Upvotes: 1
Views: 120
Reputation: 30839
Criteria definition looks okay. However, one of the reasons why it might give you an error is, you are not passing the second argument to find
method. Have a look at the javadoc here:
public List find(Query query, Class entityClass)
collection for the entity class to a List of the specified type.
Try the following:
mongoTemplate.find(new Query(new Criteria().andOperator (Criteria.where("notificationTime")
.gte(DateTime.now().minusMinutes(15).millisOfSecond())
.andOperator(Criteria.where("failureCount")).gt(3))), Response.class);
Where Response.class
is the class you want to cast your response to.
Upvotes: 1