我有一个竞赛实体:
@Entity
@Table(name = "T_CONTEST")
public class Contest {
//rest of the attributes
@Column(name = "START_TIME")
private LocalDateTime start;
@Column
@Enumerated(EnumType.STRING)
private ContestStatus status;
}
我想要获得最近开始时间且状态=待处理的第一场比赛。 我知道这可以使用自定义查询来完成,但是执行此操作的正确 Spring JPA 方法是什么? 我尝试遵循,但不正确。
Contest findTopByOrderByStartAndStatusDesc(ContestStatus status);
最佳答案
你尝试过吗
findTopByContestStatusOrderByStartDesc(ContestStatus status)
?
关于java - Spring JPA - 查找依据和排序依据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45104047/