我有表格绑定
@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);
}
我给了我一个错误。我该如何命名此查询以及如何解决此问题?
感谢您的帮助!
答案 0 :(得分:2)
我认为您的查询存在一些问题:
b.endTimeStamp e
:currentTimeStamp
,但未在查询中传递任何参数您的查询应如下所示:
@Query("from Bound b where b.startTimeStamp <= :currentTimeStamp and "
+ "b.endTimeStamp >= :currentTimeStamp")
List<Bound> findByCurrentTimeStamp(@Param("currentTimeStamp") Timestamp currentTimeStamp);