diff options
author | soshial <soshial@gmail.com> | 2021-09-18 21:15:24 +0200 |
---|---|---|
committer | soshial <soshial@gmail.com> | 2021-09-18 21:15:24 +0200 |
commit | c345945c36b4c93f2f436cf61f89495577d072ea (patch) | |
tree | 4c6e70c7c6f49fa8ee88d3cc6c0e3f96e3cdc643 /src/main/java/org/traccar/database | |
parent | a6ccfd679686cfb62f8390334229ba7fdf92eb42 (diff) | |
download | trackermap-server-c345945c36b4c93f2f436cf61f89495577d072ea.tar.gz trackermap-server-c345945c36b4c93f2f436cf61f89495577d072ea.tar.bz2 trackermap-server-c345945c36b4c93f2f436cf61f89495577d072ea.zip |
improve SQL query
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r-- | src/main/java/org/traccar/database/DataManager.java | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/database/DataManager.java b/src/main/java/org/traccar/database/DataManager.java index 15c67cb74..75ec70ea7 100644 --- a/src/main/java/org/traccar/database/DataManager.java +++ b/src/main/java/org/traccar/database/DataManager.java @@ -329,15 +329,10 @@ public class DataManager { } public Position getPrecedingPosition(long deviceId, Date date) throws SQLException { - Collection<Position> positions = QueryBuilder.create(dataSource, getQuery("database.selectPrecedingPosition")) + return QueryBuilder.create(dataSource, getQuery("database.selectPrecedingPosition")) .setLong("deviceId", deviceId) .setDate("time", date) - .executeQuery(Position.class); - if (positions.isEmpty()) { - return null; - } else { - return positions.iterator().next(); - } + .executeQuerySingle(Position.class); } public void updateLatestPosition(Position position) throws SQLException { |