目标是检索给定 UAI(枚举)的最后一个实体。不确定在 Spring Data JPA 中最好的方法是什么,这是我尝试过的(不起作用)我的实体public class AdmisHistory { // stuffs (id etc..) private Date jobExecutionDate; @Enumerated(EnumType.STRING) private UAI uai; // getters / setters}我的 JPA 存储库:public interface AdmisHistoryRepository extends CrudRepository<AdmisHistory, Long> { public AdmisHistory findFirstByOrderByUaiByJobExecutionDateDesc(UAI uai);}错误:Caused by: org.springframework.data.mapping.PropertyReferenceException: No property byJobExecutionDate found for type UAI! Traversed path: AdmisHistory.uai.
1 回答
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
您想通过 uai 匹配并获取最新记录
尝试这个:
public interface AdmisHistoryRepository extends CrudRepository<AdmisHistory, Long> {
public AdmisHistory findTopByUaiOrderByJobExecutionDateDesc(UAI uai);
}
添加回答
举报
0/150
提交
取消