我正在尝试确定移动用户的当前位置。 我在表格中有经度和经度以及时间戳" Mobilelocations"。
latitude longitude time
12.91207267 77.6323475 2015-12-10 21:47:25
12.91207268 77.6323475 2015-12-10 22:18:39
12.91207267 77.6323475 2015-12-10 02:37:14
12.91207268 77.6323475 2015-12-10 03:43:53
12.91207268 77.6323475 2015-12-10 03:22:31
12.91207268 77.6323475 2015-12-10 03:51:10
12.91207268 77.6323475 2015-12-10 04:35:21
12.91207268 77.6323475 2015-12-10 05:34:00
12.91207268 77.6323434 2015-12-10 18:48:06
12.91207268 77.6323455 2015-12-10 19:02:08
76.58753525 77.6323486 2015-12-10 19:02:25
87.34327624 77.6327356 2015-12-10 19:10:45
12.91207268 77.6323475 2015-12-10 18:45:07
12.91207268 77.6323475 2015-12-10 18:45:57
编写以下JPQL查询,以便从" MobileLocations"中检索纬度,经度和时间。表。时间选择在晚上9点到早上7点之间。预计
Query query = entityManager.createQuery("SELECT loc FROM MobileLocations loc WHERE CAST(loc.time as time)>= '21:00:00' or CAST(loc.time as time)<='07:00:00'");
但似乎它不能解决这个错误:
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: < near line 1, column 212 [SELECT NEW com.vishwas.dto.mobile.MobileLocationsDto (loc.latitude, loc.longitude,loc.time) FROM com.vishwas.entity.mobile.MobileLocations loc where CAST(loc.time as time)>= '21:00:00' or CAST(loc.time as time)=<'07:00:00'
答案 0 :(得分:0)
它也可以在不使用强制转换功能的情况下工作。试试这个:
SELECT loc FROM MobileLocations loc WHERE loc.time between '21:00:00 00:00:00' and '07:00:00 00:00:00'