All MongoDB queries done by the Spring app must have a comment, right now this is done by calling the method comment on org.springframework.data.mongodb.core.query.Query.
public <T> T findOne(Query query, Class<T> klass) {
query.comment("my comment");
return mongoTemplate.findOne(query, klass);
}
That means I have to use the MongoTemplate object for making all my queries and I'm loosing the abstraction provided by Spring Data (I have to implement the method instead of just declaring it).
Is there a way to configure Spring Data to apply a function (that will set the comment) for every queries ?
Thank you