From 9f60706d957a183433cd61de9e422e565a1f15d4 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 12 Jan 2013 00:54:34 +1300 Subject: Add latest position to device --- src/org/traccar/web/server/model/DataServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/web/server/model') diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java index 0b2a80ba..fa7a42d8 100644 --- a/src/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/org/traccar/web/server/model/DataServiceImpl.java @@ -195,8 +195,8 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService User user = getUser(); if (!user.getDevices().isEmpty()) { TypedQuery query = entityManager.createQuery( - "SELECT x FROM Position x WHERE (x.device, x.time) IN (" + - "SELECT y.device, MAX(y.time) FROM Position y WHERE y.device IN :devices GROUP BY y.device)", Position.class); + "SELECT x FROM Position x WHERE x.id IN (" + + "SELECT y.latestPosition FROM Device y WHERE y IN (:devices))", Position.class); query.setParameter("devices", user.getDevices()); positions.addAll(query.getResultList()); } -- cgit v1.2.3