aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/QueryBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/QueryBuilder.java')
-rw-r--r--src/org/traccar/database/QueryBuilder.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java
index a35b07fee..386ed86d7 100644
--- a/src/org/traccar/database/QueryBuilder.java
+++ b/src/org/traccar/database/QueryBuilder.java
@@ -201,6 +201,15 @@ public class QueryBuilder {
public void process(T object, ResultSet resultSet) throws SQLException;
}
+ public <T extends Factory> T executeQuerySingle(T prototype) throws SQLException {
+ Collection<T> result = executeQuery(prototype);
+ if (!result.isEmpty()) {
+ return result.iterator().next();
+ } else {
+ return null;
+ }
+ }
+
public <T extends Factory> Collection<T> executeQuery(T prototype) throws SQLException {
List<T> result = new LinkedList<T>();