From a7e159b17220378661befd26dfefcd02a3fbadd7 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Fri, 25 Sep 2015 16:55:58 -0400 Subject: [PATCH] Add QueryMapper.noBind, which is skipped if sent in as one of the bindObjects --- .../main/java/com/moparisthebest/jdbc/ListQueryMapper.java | 2 +- .../src/main/java/com/moparisthebest/jdbc/QueryMapper.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java index 9fe3aff..cab30bb 100644 --- a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java +++ b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java @@ -192,7 +192,7 @@ public class ListQueryMapper extends QueryMapper { private static StringBuilder recursiveReplace(final StringBuilder sb, final Object... bindObjects) { if (bindObjects != null && bindObjects.length > 0) { for (Object o : bindObjects) { - if (o != null) { + if (o != null && o != QueryMapper.noBind) { if (o instanceof InList.InListObject) { final int startIndex = sb.indexOf(inListReplace); if (startIndex < -1) diff --git a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/QueryMapper.java b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/QueryMapper.java index fb483bf..a9907f5 100644 --- a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/QueryMapper.java +++ b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/QueryMapper.java @@ -12,6 +12,8 @@ import static com.moparisthebest.jdbc.TryClose.tryClose; public class QueryMapper implements Closeable { + public static final Object noBind = new Object(); + static { try{ final Class ensureContext = Class.forName(System.getProperty("QueryMapper.ensureContext.class", "com.gcl.containerless.EnsureContext")); @@ -203,7 +205,7 @@ public class QueryMapper implements Closeable { if (bindObjects != null && bindObjects.length > 0) { for (Object o : bindObjects) { if (o != null) { - if (o == InList.InListObject.empty) { + if (o == InList.InListObject.empty || o == noBind) { continue; // ignore } else if (o instanceof BindInList.BindInListObject) { if (((BindInList.BindInListObject) o).getBindObjects() != null)