diff options
author | ninioe <ninioe@gmail.com> | 2016-07-19 09:07:23 +0300 |
---|---|---|
committer | ninioe <ninioe@gmail.com> | 2016-07-19 09:07:23 +0300 |
commit | ef40f3317392068692606b484c6782b95b554cbf (patch) | |
tree | 41c48e6c87620a6444aed0ad5706a94e26b1662d /src/org/traccar/database/QueryBuilder.java | |
parent | 04627d7473e4ea21d6ecd950cbb3fdd6fa249429 (diff) | |
parent | d3e063cf9de8a45bed4dfe87b73aadfd8d2edeab (diff) | |
download | traccar-server-ef40f3317392068692606b484c6782b95b554cbf.tar.gz traccar-server-ef40f3317392068692606b484c6782b95b554cbf.tar.bz2 traccar-server-ef40f3317392068692606b484c6782b95b554cbf.zip |
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'src/org/traccar/database/QueryBuilder.java')
-rw-r--r-- | src/org/traccar/database/QueryBuilder.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index 73569ac2a..1a83daab9 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -173,9 +173,17 @@ public final class QueryBuilder { } public QueryBuilder setLong(String name, long value) throws SQLException { + return setLong(name, value, false); + } + + public QueryBuilder setLong(String name, long value, boolean nullIfZero) throws SQLException { for (int i : indexes(name)) { try { - statement.setLong(i, value); + if (value == 0 && nullIfZero) { + statement.setNull(i, Types.INTEGER); + } else { + statement.setLong(i, value); + } } catch (SQLException error) { statement.close(); connection.close(); @@ -245,7 +253,7 @@ public final class QueryBuilder { } else if (method.getReturnType().equals(int.class)) { setInteger(name, (Integer) method.invoke(object)); } else if (method.getReturnType().equals(long.class)) { - setLong(name, (Long) method.invoke(object)); + setLong(name, (Long) method.invoke(object), name.endsWith("Id")); } else if (method.getReturnType().equals(double.class)) { setDouble(name, (Double) method.invoke(object)); } else if (method.getReturnType().equals(String.class)) { |