带弹簧数据的日期

时间:2015-04-20 15:21:22

标签: spring spring-data

我有两个日期作为参数,我需要这些日期之间的所有记录。我的问题是我的查询不起作用,因为正在检索一个空列表。这是我的问题:

@Query("select ta from TravelerAdventureEntity ta  WHERE ta.fromDate <= :from and ta.toDate >= :to and ta.saveAndShare =1")
public List<TravelerAdventureEntity> findTravelersByDate(@Param("from") Date from,@Param("to") Date to,Pageable page);

有人知道春天数据中日期的工作原理吗? 谢谢。

2 个答案:

答案 0 :(得分:2)

fromDate应该是开始,结束日期,对吧? 没有冒犯,但我认为你累了或者其他东西:)

@Query("select ta from TravelerAdventureEntity ta  WHERE ta.fromDate >= :from and ta.toDate <= :to and ta.saveAndShare =1")
public List<TravelerAdventureEntity> findTravelersByDate(@Param("from") Date from,@Param("to") Date to,Pageable page);

答案 1 :(得分:0)

是的,你是对的!在发布我的回答之前,我已经改变了日期。在开始是好的。还是非常感谢。 我刚刚发现了我的错误,它出现在参数页面中,我正在寻找没有结果的页面。