diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-25 15:31:03 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-25 15:31:03 +1200 |
commit | 6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4 (patch) | |
tree | 8cba8784f507140e871e290229ab9841034a0c07 /src/org/traccar/database/QueryBuilder.java | |
parent | c8e5c5e3da63646fd7c84d4f522bc8d7e5109982 (diff) | |
parent | f35961c2f4a3104a009d6e3cd6bc862e6810b998 (diff) | |
download | trackermap-server-6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4.tar.gz trackermap-server-6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4.tar.bz2 trackermap-server-6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4.zip |
Merge pull request #3385 from Abyss777/optimize_managers
Few managers optimizations
Diffstat (limited to 'src/org/traccar/database/QueryBuilder.java')
-rw-r--r-- | src/org/traccar/database/QueryBuilder.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index 440690a76..af33458a8 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.traccar.Context; import org.traccar.helper.Log; import org.traccar.model.MiscFormatter; +import org.traccar.model.Permission; import javax.sql.DataSource; import java.io.IOException; @@ -488,19 +489,19 @@ public final class QueryBuilder { return 0; } - public <T> Collection<Map<String, T>> executeMapQuery(Class<T> clazz) throws SQLException { - List<Map<String, T>> result = new LinkedList<>(); + public Collection<Permission> executePermissionsQuery() throws SQLException, ClassNotFoundException { + List<Permission> result = new LinkedList<>(); if (query != null) { try { try (ResultSet resultSet = statement.executeQuery()) { ResultSetMetaData resultMetaData = resultSet.getMetaData(); while (resultSet.next()) { - LinkedHashMap<String, T> map = new LinkedHashMap<>(); + LinkedHashMap<String, Long> map = new LinkedHashMap<>(); for (int i = 1; i <= resultMetaData.getColumnCount(); i++) { String label = resultMetaData.getColumnLabel(i); - map.put(label, resultSet.getObject(label, clazz)); + map.put(label, resultSet.getLong(label)); } - result.add(map); + result.add(new Permission(map)); } } } finally { |