我有表绑定

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "boundId", unique = true, nullable = false)
private long boundId;

@Column
@Basic
private Timestamp startTimeStamp;

@Column
@Basic
private Timestamp endTimeStamp;


我创建查询:

public interface BoundsDataRepository extends CrudRepository<Bound, Long> {
   @Query("from Bound b where b.startTimeStamp s <=:currentTimeStamp and b.endTimeStamp e>=:currentTimeStamp")
   List<Bound> findByCurrentTimeStamp(Timestamp currentTimeStamp);
}


我给我一个错误。我该如何命名该查询以及如何解决该问题?

感谢帮助!

最佳答案

我认为您在查询中遇到了一些问题:


您无需在列名称b.endTimeStamp e中使用别名
您使用参数:currentTimeStamp,但未在查询中传递任何参数


您的查询应类似于:

@Query("from Bound b where b.startTimeStamp <= :currentTimeStamp and "
        + "b.endTimeStamp >= :currentTimeStamp")
List<Bound> findByCurrentTimeStamp(@Param("currentTimeStamp") Timestamp currentTimeStamp);

07-25 23:52