Spring boot 用于比较日期的Spring Boot JPA规范
我需要找到在用户传递的日期之间的表记录。我正试图为此编写一个规范,但它向我显示编译时错误,如下所示:Spring boot 用于比较日期的Spring Boot JPA规范,spring-boot,jpa,spring-data-jpa,predicate,criteria-api,Spring Boot,Jpa,Spring Data Jpa,Predicate,Criteria Api,我需要找到在用户传递的日期之间的表记录。我正试图为此编写一个规范,但它向我显示编译时错误,如下所示: The method between(Expression<? extends Y>, Expression<? extends Y>, Expression<? extends Y>) in the type CriteriaBuilder is not applicable for the arguments (Expression<Date&g
The method between(Expression<? extends Y>, Expression<? extends Y>, Expression<? extends Y>)
in the type CriteriaBuilder
is not applicable for the arguments (Expression<Date>, Object, Object)
从存储库中提取记录的服务
if(!Utility.isNull(Id)){
idSpec = new ScheduleClassSpecification(new SearchCriteria("Student",":",Id));
}
Page<SCOutput> listreturn = scRepo.findAll(Specification.where(idSpec), SCOutput.class,new PageRequest(0, 100));
if(!Utility.isNull(Id)){
idSpec=新的ScheduleClassSpecification(新的搜索条件(“学生”,“学生”,“学生:”Id));
}
Page listreturn=scRepo.findAll(Specification.where(idSpec),SCOutput.class,new PageRequest(01100));
编译器错误告诉您需要一个表达式
通过将criteria.getValue()
替换为可以很容易地做到这一点。您可以尝试将criteria.getValue()
键入到Date
吗?
public class SearchCriteria {
private String key;
private String operation;
private Object value;}
if(!Utility.isNull(Id)){
idSpec = new ScheduleClassSpecification(new SearchCriteria("Student",":",Id));
}
Page<SCOutput> listreturn = scRepo.findAll(Specification.where(idSpec), SCOutput.class,new PageRequest(0, 100));