【发布时间】:2019-11-21 17:22:06
【问题描述】:
我有一个名为 Employee 的文档。我想查询2019年到2020年之间所有指定为“开发者”且加入日期为的员工。
class Employee{
private String name;
private String designation;
private Date joiningDate;
}
**// i want where condition on designation to be included in the following**
@Repository
public interface EmployeeRepository extends MongoRepository<Employee, String> {
@Query("{'joiningDate' : {$gte : ?0, $lte : ?1}}")
public List<Employee> findByJoiningDateBetween(LocalDateTime startTime, LocalDateTime endTime);
}
【问题讨论】:
-
您在使用 JPA 吗?为什么要扩展
MongoRepository? -
@KenChan 是的。我需要我已经在条件之间。现在我想在另一列上添加 where 条件
-
那为什么要扩展
MongoRepository呢? JPA与RDBMS一起使用,与MongoDB完全不同...... -
@KenChan 对不起。这是 Mongo DB 而不是 JPA。我会更新问题。
标签: spring mongodb mongodb-query spring-data-mongodb