1

我有一个包含剪辑列表的数据库。每个剪辑都有一个 startTime 和一个 endTime,两个时间戳都带有时区。我想要做的是获取时间范围内的所有剪辑(开始 - 结束)。我的 java 程序中有两个 Date 类型的对象,我从 hibernate 创建了一个 SQL 查询:

select * from clips where (start_time IN(?,?) or end_time IN(?,?)) and clips.mediaid=? order by clips.id ASC

我使用 SQLQuery 的 setDate(int arg0, Date arg1) 方法设置了 Date 参数,但是当我执行时,我只在日期范围( start - end )至少相差一整天时才得到结果。就好像结果 sql 查询完全忽略了时差,只比较日期(年、月、日)。

4

1 回答 1

0

我认为应该是

(start_time >= ? and end_time <= ?) 
于 2012-12-20T15:02:15.793 回答