我有一个类型为datetime的时间戳字段的表。我需要将定义的开始时间和结束时间之间的数据聚合到代表等长时间间隔的x组中,其中x作为函数参数提供。按时间间隔休眠组
什么是最好的方式与Hibernate做到这一点?
编辑:一些解释
MySQL表:
data_ts: datetime pk
value1 : int
value2 : bigint
...
实体类:
Calendar dataTs;
Integer value1;
BigDecimal value2;
...
我要寻找一个HQL查询,确实有点像
select max(c.value1), avg(c.value2) from MyClass c
where c.dataTs between :start and :end group by <interval>
谁在哪里le时间段被分成x个相同大小的时间间隔。
实施例:
Start : 2008-10-01 00:00:00
End : 2008-10-03 00:00:00 (2 days)
Groups: 32
将需要以1.5小时的时间间隔进行分组(48小时/ 32):
2008-10-01 00:00:00 - 2008-10-01 01:29:59
2008-10-01 01:30:00 - 2008-10-01 02:59:59
2008-10-01 02:00:00 - 2008-10-01 04:29:59
...