我的表描述是
desc sensor_log_history;
+-------------+-----------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-----------------+------+-----+-------------------+-----------------------------+
| AutoPk | int(4) unsigned | NO | MUL | NULL | |
| sensorName | varchar(20) | NO | | NULL | |
| SensorValue | double(65,2) | NO | | 0.00 | |
| timest | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+-------------+-----------------+------+-----+-------------------+-----------------------------+
4 rows in set (0.00 sec)
我的查询是
SELECT AutoPk,Result1.sensorName, SensorValue,Result1.timest FROM (SELECT MAX(timest) AS timest, sensorName FROM sensor_log_history GROUP BY sensorName) AS Result1 INNER JOIN sensor_log_history ON Result1.timest = sensor_log_history.timest WHERE Result1.sensorName = sensor_log_history.sensorName ;
如何使用休眠执行此查询。Hibernate 应该返回一个类型为sensor_log_history
.? 的对象列表。