You are calling the mongoOperations
instance directly and not first retrieving a collection. So much like the findAll
method you have implemented you also need the form that contains the collection as an argument:
public NewsEntity getNewsDetail(Long id) {
return mongoOperations.findOne(
Query.query(Criteria.where("_id").is(id)),
NewsEntity.class,
COLLECTION_NAME
);
}
This is covered in the documentation for findOne
, also see the available method signatures in the summary.