Query with sort() and limit() in Spring Repository interface
I'm new to Spring Data with MongoDB and would like to have an automagically generated query method inside my MongoRepository extension interface which requires filtering, sorting and limiting. The query looks like this: // 'created' is the field I need to sort against find({state:'ACTIVE'}).sort({created:-1}).limit(1) The repository interface looks like this: public interface JobRepository extends MongoRepository<Job, String> { @Query("{ state: 'ACTIVE', userId: ?0 }") List<Job> findActiveByUserId(String userId); // The next line is the problem, it wont work since // it's not in the format