First step towards deleting ListQueryMapper, moving inList up to QueryMapper

This commit is contained in:
Travis Burtrum 2019-01-15 23:30:00 -05:00
parent 508b7cfc51
commit 3a562ad88a
7 changed files with 212 additions and 1794 deletions

View File

@ -63,8 +63,6 @@ finishFile "src/main/java/com/moparisthebest/jdbc/ResultSetMapper.java"
query="$(prepareFile "src/main/java/com/moparisthebest/jdbc/QueryMapper.java")"
caching_query="$(prepareFile "src/main/java/com/moparisthebest/jdbc/CachingQueryMapper.java")"
null_query="$(prepareFile "src/main/java/com/moparisthebest/jdbc/NullQueryMapper.java")"
list_query="$(prepareFile "src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java")"
null_list_query="$(prepareFile "src/main/java/com/moparisthebest/jdbc/NullListQueryMapper.java")"
cat src/main/java/com/moparisthebest/jdbc/ResultSetMapper.java | grep public | grep '(ResultSet rs' | egrep -v '(int arrayMaxLength|Calendar cal)' | while read method
do
@ -72,7 +70,7 @@ do
method_name=$(echo $method | egrep -o '[^ ]+\(')
echo "QueryMapper.$method_name)"
[ "$method_name" == 'toStream(' ] && echo -e '\t//IFJAVA8_START\n' | tee -a "$query" "$caching_query" "$null_query" "$list_query" "$null_list_query" >/dev/null
[ "$method_name" == 'toStream(' ] && echo -e '\t//IFJAVA8_START\n' | tee -a "$query" "$caching_query" "$null_query" >/dev/null
# QueryMapper.java
cat >> "$query" <<EOF
@ -89,7 +87,7 @@ EOF
$(echo $method | sed -e 's/ResultSet rs/String sql/' -e 's/) {/, final Object... bindObjects) throws SQLException {/')
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.$method_name$(echo $method | sed -e 's/^.*(//' -e 's/final //g' -e 's/, [^ ]* /, /g' -e 's/ResultSet rs/ps/' -e 's/) {/, bindObjects);/')
} finally {
tryClose(ps);
@ -104,7 +102,7 @@ EOF
cat >> "$caching_query" <<EOF
@Override
$(echo $method | sed -e 's/ResultSet rs/String sql/' -e 's/) {/, final Object... bindObjects) throws SQLException {/')
return super.$method_name$(echo $method | sed -e 's/^.*(//' -e 's/final //g' -e 's/, [^ ]* /, /g' -e 's/ResultSet rs/getPreparedStatement(sql)/' -e 's/) {/, bindObjects);/')
return super.$method_name$(echo $method | sed -e 's/^.*(//' -e 's/final //g' -e 's/, [^ ]* /, /g' -e 's/ResultSet rs/getPreparedStatement(sql, bindObjects)/' -e 's/) {/, bindObjects);/')
}
EOF
@ -125,28 +123,12 @@ EOF
}
EOF
done | tee -a "$null_query" >> "$null_list_query"
done >> "$null_query"
# ListQueryMapper.java
cat >> "$list_query" <<EOF
@Override
$(echo $method | sed -e 's/ResultSet rs/PreparedStatement ps/' -e 's/) {/, final Object... bindObjects) throws SQLException {/')
return delegate.$method_name$(echo $method | sed -e 's/^.*(//' -e 's/final //g' -e 's/, [^ ]* /, /g' -e 's/ResultSet rs/ps/' -e 's/) {/, bindObjects);/')
}
@Override
$(echo $method | sed -e 's/ResultSet rs/String sql/' -e 's/) {/, final Object... bindObjects) throws SQLException {/')
return delegate.$method_name$(echo $method | sed -e 's/^.*(//' -e 's/final //g' -e 's/, [^ ]* /, /g' -e 's/ResultSet rs/prepareSql(sql, bindObjects)/' -e 's/) {/, bindObjects);/')
}
EOF
[ "$method_name" == 'toStream(' ] && echo -e '\t//IFJAVA8_END\n' | tee -a "$query" "$caching_query" "$null_query" "$list_query" "$null_list_query" >/dev/null
[ "$method_name" == 'toStream(' ] && echo -e '\t//IFJAVA8_END\n' | tee -a "$query" "$caching_query" "$null_query" >/dev/null
done
finishFile "src/main/java/com/moparisthebest/jdbc/QueryMapper.java"
finishFile "src/main/java/com/moparisthebest/jdbc/CachingQueryMapper.java"
finishFile "src/main/java/com/moparisthebest/jdbc/NullQueryMapper.java"
finishFile "src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java"
finishFile "src/main/java/com/moparisthebest/jdbc/NullListQueryMapper.java"

View File

@ -92,21 +92,18 @@ public class CachingQueryMapper extends QueryMapper {
this(null, null, factory, null);
}
protected PreparedStatement getPreparedStatement(String sql) throws SQLException {
return getPreparedStatement(sql, defaultPsf);
}
/**
* This could perhaps end up caching something it shouldn't, as psf could return a different PreparedStatement
* for a given sql, we are going to assume this would never happen, if it could, don't use CachingQueryMapper or
* override this method, whatever you want.
*/
protected PreparedStatement getPreparedStatement(final String sql, final PreparedStatementFactory psf) throws SQLException {
PreparedStatement ps = cache.get(sql);
protected PreparedStatement getPreparedStatement(final String sql, final PreparedStatementFactory psf, final Object... bindObjects) throws SQLException {
final String preparedSql = prepareInListSql(sql, bindObjects);
PreparedStatement ps = cache.get(preparedSql);
if (ps == null) {
//System.out.println("cache miss");
ps = psf.prepareStatement(conn, sql);
cache.put(sql, ps);
ps = psf.prepareStatement(conn, preparedSql);
cache.put(preparedSql, ps);
}
//else System.out.println("cache hit");
return ps;
@ -133,53 +130,53 @@ public class CachingQueryMapper extends QueryMapper {
@Override
public int executeUpdate(String sql, Object... bindObjects) throws SQLException {
return super.executeUpdate(getPreparedStatement(sql), bindObjects);
return super.executeUpdate(getPreparedStatement(sql, bindObjects), bindObjects);
}
@Override
public boolean executeUpdateSuccess(String sql, Object... bindObjects) throws SQLException {
return super.executeUpdateSuccess(getPreparedStatement(sql), bindObjects);
return super.executeUpdateSuccess(getPreparedStatement(sql, bindObjects), bindObjects);
}
@Override
public Long insertGetGeneratedKey(String sql, Object... bindObjects) throws SQLException {
return super.insertGetGeneratedKey(getPreparedStatement(sql, getSingleColumnPreparedStatementFactory()), bindObjects);
return super.insertGetGeneratedKey(getPreparedStatement(sql, getSingleColumnPreparedStatementFactory(), bindObjects), bindObjects);
}
@Override
public <T> T insertGetGeneratedKeyType(String sql, final PreparedStatementFactory psf, TypeReference<T> typeReference, Object... bindObjects) throws SQLException {
return super.insertGetGeneratedKeyType(getPreparedStatement(sql, psf), typeReference, bindObjects);
return super.insertGetGeneratedKeyType(getPreparedStatement(sql, psf, bindObjects), typeReference, bindObjects);
}
// these grab ResultSets from the database
@Override
public ResultSet toResultSet(final String sql, final PreparedStatementFactory psf, final Object... bindObjects) throws SQLException {
return super.toResultSet(getPreparedStatement(sql, psf), bindObjects);
return super.toResultSet(getPreparedStatement(sql, psf, bindObjects), bindObjects);
}
// DO NOT EDIT BELOW THIS LINE, OR CHANGE THIS COMMENT, CODE AUTOMATICALLY GENERATED BY genQueryMapper.sh
@Override
public <T> T toObject(String sql, Class<T> componentType, final Object... bindObjects) throws SQLException {
return super.toObject(getPreparedStatement(sql), componentType, bindObjects);
return super.toObject(getPreparedStatement(sql, bindObjects), componentType, bindObjects);
}
@Override
public <T> ResultSetIterable<T> toResultSetIterable(String sql, Class<T> componentType, final Object... bindObjects) throws SQLException {
return super.toResultSetIterable(getPreparedStatement(sql), componentType, bindObjects);
return super.toResultSetIterable(getPreparedStatement(sql, bindObjects), componentType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> ResultSetIterable<Map<String, V>> toResultSetIterable(String sql, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toResultSetIterable(getPreparedStatement(sql), componentType, mapValType, bindObjects);
return super.toResultSetIterable(getPreparedStatement(sql, bindObjects), componentType, mapValType, bindObjects);
}
//IFJAVA8_START
@Override
public <T> Stream<T> toStream(String sql, Class<T> componentType, final Object... bindObjects) throws SQLException {
return super.toStream(getPreparedStatement(sql), componentType, bindObjects);
return super.toStream(getPreparedStatement(sql, bindObjects), componentType, bindObjects);
}
//IFJAVA8_END
@ -188,164 +185,164 @@ public class CachingQueryMapper extends QueryMapper {
@Override
public <T extends Map<String, V>, V> Stream<Map<String, V>> toStream(String sql, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toStream(getPreparedStatement(sql), componentType, mapValType, bindObjects);
return super.toStream(getPreparedStatement(sql, bindObjects), componentType, mapValType, bindObjects);
}
//IFJAVA8_END
@Override
public <T extends Map<String, V>, V> Map<String, V> toSingleMap(String sql, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toSingleMap(getPreparedStatement(sql), componentType, mapValType, bindObjects);
return super.toSingleMap(getPreparedStatement(sql, bindObjects), componentType, mapValType, bindObjects);
}
@Override
public <V> Map<String, V> toSingleMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toSingleMap(getPreparedStatement(sql), mapValType, bindObjects);
return super.toSingleMap(getPreparedStatement(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <T> T toType(String sql, TypeReference<T> typeReference, final Object... bindObjects) throws SQLException {
return super.toType(getPreparedStatement(sql), typeReference, bindObjects);
return super.toType(getPreparedStatement(sql, bindObjects), typeReference, bindObjects);
}
@Override
public <T extends Collection<E>, E> T toCollection(String sql, final Class<T> collectionType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return super.toCollection(getPreparedStatement(sql), collectionType, componentType, bindObjects);
return super.toCollection(getPreparedStatement(sql, bindObjects), collectionType, componentType, bindObjects);
}
@Override
public <T extends Collection<E>, E> T toCollection(String sql, T list, Class<E> componentType, final Object... bindObjects) throws SQLException {
return super.toCollection(getPreparedStatement(sql), list, componentType, bindObjects);
return super.toCollection(getPreparedStatement(sql, bindObjects), list, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E> T toMap(String sql, T map, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return super.toMap(getPreparedStatement(sql), map, mapKeyType, componentType, bindObjects);
return super.toMap(getPreparedStatement(sql, bindObjects), map, mapKeyType, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return super.toMapCollection(getPreparedStatement(sql), returnType, mapKeyType, collectionType, componentType, bindObjects);
return super.toMapCollection(getPreparedStatement(sql, bindObjects), returnType, mapKeyType, collectionType, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(String sql, T map, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return super.toMapCollection(getPreparedStatement(sql), map, mapKeyType, collectionType, componentType, bindObjects);
return super.toMapCollection(getPreparedStatement(sql, bindObjects), map, mapKeyType, collectionType, componentType, bindObjects);
}
@Override
public <T> ListIterator<T> toListIterator(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
return super.toListIterator(getPreparedStatement(sql), type, bindObjects);
return super.toListIterator(getPreparedStatement(sql, bindObjects), type, bindObjects);
}
@Override
public <T> Iterator<T> toIterator(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
return super.toIterator(getPreparedStatement(sql), type, bindObjects);
return super.toIterator(getPreparedStatement(sql, bindObjects), type, bindObjects);
}
@Override
public <T> T[] toArray(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
return super.toArray(getPreparedStatement(sql), type, bindObjects);
return super.toArray(getPreparedStatement(sql, bindObjects), type, bindObjects);
}
@Override
public <E> List<E> toList(String sql, Class<E> componentType, final Object... bindObjects) throws SQLException {
return super.toList(getPreparedStatement(sql), componentType, bindObjects);
return super.toList(getPreparedStatement(sql, bindObjects), componentType, bindObjects);
}
@Override
public <K, E> Map<K, E> toMap(String sql, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return super.toMap(getPreparedStatement(sql), mapKeyType, componentType, bindObjects);
return super.toMap(getPreparedStatement(sql, bindObjects), mapKeyType, componentType, bindObjects);
}
@Override
public <K, E extends List<C>, C> Map<K, E> toMapList(String sql, Class<K> mapKeyType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return super.toMapList(getPreparedStatement(sql), mapKeyType, componentType, bindObjects);
return super.toMapList(getPreparedStatement(sql, bindObjects), mapKeyType, componentType, bindObjects);
}
@Override
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(String sql, final Class<T> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toCollectionMap(getPreparedStatement(sql), collectionType, componentType, mapValType, bindObjects);
return super.toCollectionMap(getPreparedStatement(sql, bindObjects), collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(String sql, T list, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toCollectionMap(getPreparedStatement(sql), list, componentType, mapValType, bindObjects);
return super.toCollectionMap(getPreparedStatement(sql, bindObjects), list, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapMap(getPreparedStatement(sql), returnType, mapKeyType, componentType, mapValType, bindObjects);
return super.toMapMap(getPreparedStatement(sql, bindObjects), returnType, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(String sql, T map, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapMap(getPreparedStatement(sql), map, mapKeyType, componentType, mapValType, bindObjects);
return super.toMapMap(getPreparedStatement(sql, bindObjects), map, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapCollectionMap(getPreparedStatement(sql), returnType, mapKeyType, collectionType, componentType, mapValType, bindObjects);
return super.toMapCollectionMap(getPreparedStatement(sql, bindObjects), returnType, mapKeyType, collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(String sql, T map, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapCollectionMap(getPreparedStatement(sql), map, mapKeyType, collectionType, componentType, mapValType, bindObjects);
return super.toMapCollectionMap(getPreparedStatement(sql, bindObjects), map, mapKeyType, collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> ListIterator<Map<String, V>> toListIteratorMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toListIteratorMap(getPreparedStatement(sql), type, mapValType, bindObjects);
return super.toListIteratorMap(getPreparedStatement(sql, bindObjects), type, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Iterator<Map<String, V>> toIteratorMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toIteratorMap(getPreparedStatement(sql), type, mapValType, bindObjects);
return super.toIteratorMap(getPreparedStatement(sql, bindObjects), type, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Map<String, V>[] toArrayMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toArrayMap(getPreparedStatement(sql), type, mapValType, bindObjects);
return super.toArrayMap(getPreparedStatement(sql, bindObjects), type, mapValType, bindObjects);
}
@Override
public <E extends Map<String, V>, V> List<Map<String, V>> toListMap(String sql, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toListMap(getPreparedStatement(sql), componentType, mapValType, bindObjects);
return super.toListMap(getPreparedStatement(sql, bindObjects), componentType, mapValType, bindObjects);
}
@Override
public <K, E extends Map<String, V>, V> Map<K, Map<String, V>> toMapMap(String sql, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapMap(getPreparedStatement(sql), mapKeyType, componentType, mapValType, bindObjects);
return super.toMapMap(getPreparedStatement(sql, bindObjects), mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <K, E extends Map<String, V>, V> Map<K, List<Map<String, V>>> toMapListMap(String sql, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapListMap(getPreparedStatement(sql), mapKeyType, componentType, mapValType, bindObjects);
return super.toMapListMap(getPreparedStatement(sql, bindObjects), mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <V> ListIterator<Map<String, V>> toListIteratorMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toListIteratorMap(getPreparedStatement(sql), mapValType, bindObjects);
return super.toListIteratorMap(getPreparedStatement(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <V> Iterator<Map<String, V>> toIteratorMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toIteratorMap(getPreparedStatement(sql), mapValType, bindObjects);
return super.toIteratorMap(getPreparedStatement(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <V> List<Map<String, V>> toListMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toListMap(getPreparedStatement(sql), mapValType, bindObjects);
return super.toListMap(getPreparedStatement(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <K, V> Map<K, Map<String, V>> toMapMap(String sql, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapMap(getPreparedStatement(sql), mapKeyType, mapValType, bindObjects);
return super.toMapMap(getPreparedStatement(sql, bindObjects), mapKeyType, mapValType, bindObjects);
}
@Override
public <K, V> Map<K, List<Map<String, V>>> toMapListMap(String sql, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return super.toMapListMap(getPreparedStatement(sql), mapKeyType, mapValType, bindObjects);
return super.toMapListMap(getPreparedStatement(sql, bindObjects), mapKeyType, mapValType, bindObjects);
}
}

View File

@ -15,59 +15,19 @@ import java.util.stream.Stream;
public class ListQueryMapper extends QueryMapper {
private static final InList defaultInList;
static {
InList def;
try {
final String inListClassName = System.getProperty("QueryMapper.defaultInList.class");
if(inListClassName != null) {
final Class<?> inListClass = Class.forName(inListClassName);
final Method method = inListClass.getMethod(System.getProperty("QueryMapper.defaultInList.method", "instance"));
def = (InList) method.invoke(null);
} else {
// todo: change default to OPTIMAL ?
final String type = System.getProperty("queryMapper.databaseType", System.getProperty("jdbcMapper.databaseType", "BIND"));
if(type.equals("OPTIMAL")) {
def = OptimalInList.instance();
} else {
switch (JdbcMapper.DatabaseType.valueOf(type)) {
case DEFAULT:
case BIND:
def = BindInList.instance();
break;
case ANY:
def = ArrayInList.instance();
break;
case ORACLE:
def = OracleArrayInList.instance();
break;
case UNNEST:
def = UnNestArrayInList.instance();
break;
default:
throw new RuntimeException("Invalid queryMapper.databaseType: " + type);
}
}
}
} catch (Throwable e) {
// NEVER ignore
throw new RuntimeException(e);
}
defaultInList = def;
}
protected final QueryMapper delegate;
protected final boolean closeDelegate;
protected final InList inList;
public static final String inListReplace = "{inList}";
protected ListQueryMapper(Connection conn, String jndiName, Factory<Connection> factory, QueryMapper delegate, ResultSetMapper cm, InList inList) {
this.inList = inList.instance(conn);
this.closeDelegate = delegate == null;
this.delegate = this.closeDelegate ? new QueryMapper(conn, jndiName, factory, cm) :
(delegate instanceof ListQueryMapper ? ((ListQueryMapper)delegate).delegate : delegate);
protected ListQueryMapper(Connection conn, String jndiName, Factory<Connection> factory, final QueryMapper d, ResultSetMapper cm, InList inList, boolean closeDelegate) {
super(d == null ? conn : d.conn, jndiName, factory, d == null ? cm : d.cm, d == null ? inList : d.inList);
this.closeDelegate = closeDelegate;
this.delegate = d;
}
protected ListQueryMapper(Connection conn, String jndiName, Factory<Connection> factory, final QueryMapper d, ResultSetMapper cm, InList inList) {
this(conn, jndiName, factory, d, cm, inList, false);
}
protected ListQueryMapper(Connection conn, String jndiName, Factory<Connection> factory, QueryMapper delegate, ResultSetMapper cm) {
@ -75,18 +35,7 @@ public class ListQueryMapper extends QueryMapper {
}
public ListQueryMapper(InList inList, QueryMapper delegate, boolean closeDelegate) {
this.delegate = delegate;
this.closeDelegate = closeDelegate;
this.inList = inList;
}
/**
* Only meant to be called by implementing classes
*/
protected ListQueryMapper() {
this.delegate = null;
this.closeDelegate = false;
this.inList = null;
this(null, null, null, delegate, null, inList, closeDelegate);
}
public ListQueryMapper(QueryMapper delegate, InList inList) {
@ -161,555 +110,10 @@ public class ListQueryMapper extends QueryMapper {
return of(qm, defaultInList);
}
public <T> InList.InListObject inList(final String columnName, final Collection<T> values) throws SQLException {
return this.inList.inList(delegate.conn, columnName, values);
}
public <T> InList.InListObject notInList(final String columnName, final Collection<T> values) throws SQLException {
return this.inList.notInList(delegate.conn, columnName, values);
}
// these update the database
@Override
public int executeUpdate(final PreparedStatement ps, final Object... bindObjects) throws SQLException {
return delegate.executeUpdate(ps, bindObjects);
}
@Override
public boolean executeUpdateSuccess(final PreparedStatement ps, final Object... bindObjects) throws SQLException {
return delegate.executeUpdateSuccess(ps, bindObjects);
}
@Override
public Long insertGetGeneratedKey(PreparedStatement ps, Object... bindObjects) throws SQLException {
return delegate.insertGetGeneratedKey(ps, bindObjects);
}
@Override
public <T> T insertGetGeneratedKeyType(PreparedStatement ps, TypeReference<T> typeReference, Object... bindObjects) throws SQLException {
return delegate.insertGetGeneratedKeyType(ps, typeReference, bindObjects);
}
// these update the database using UpdateableDTOs
@Override
public int updateRows(final UpdateableDTO dto) throws SQLException {
return delegate.updateRows(dto);
}
@Override
public int updateRows(final Collection<UpdateableDTO> dtos) throws SQLException {
return delegate.updateRows(dtos);
}
@Override
public int updateRows(final UpdateableDTO[] dtos) throws SQLException {
return delegate.updateRows(dtos);
}
@Override
public int insertRows(final UpdateableDTO dto) throws SQLException {
return delegate.insertRows(dto);
}
@Override
public int insertRows(final Collection<UpdateableDTO> dtos) throws SQLException {
return delegate.insertRows(dtos);
}
@Override
public int insertRows(final UpdateableDTO[] dtos) throws SQLException {
return delegate.insertRows(dtos);
}
// these grab ResultSets from the database
@Override
public ResultSet toResultSet(PreparedStatement ps, Object... bindObjects) throws SQLException {
return delegate.toResultSet(ps, bindObjects);
}
// these are standard getters
@Override
public ResultSetMapper getCustomResultSetMapper() {
return delegate.getCustomResultSetMapper();
}
@Override
public Connection getConnection() {
return delegate.getConnection();
}
// these just delegate and change no functionality
@Override
public void close() {
if(closeDelegate)
delegate.close();
}
// and these are standard
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final ListQueryMapper that = (ListQueryMapper) o;
if (delegate != null ? !delegate.equals(that.delegate) : that.delegate != null) return false;
if (inList != null ? !inList.equals(that.inList) : that.inList != null) return false;
return true;
}
@Override
public int hashCode() {
int result = delegate != null ? delegate.hashCode() : 0;
result = 31 * result + (inList != null ? inList.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "ListQueryMapper{" +
"delegate=" + delegate +
", inList=" + inList +
"} " + super.toString();
}
// begin of ListQueryMapper specific methods
private static StringBuilder recursiveReplace(final StringBuilder sb, final Object... bindObjects) {
if (bindObjects != null && bindObjects.length > 0) {
for (Object o : bindObjects) {
if (o != null && o != QueryMapper.noBind) {
if (o instanceof InList.InListObject) {
final int startIndex = sb.indexOf(inListReplace);
if (startIndex < -1)
return sb; // we've replaced all, maybe an error? meh
sb.replace(startIndex, startIndex + inListReplace.length(), o.toString());
} else if (o instanceof Object[]) {
recursiveReplace(sb, (Object[]) o);
} else if (o instanceof Collection) {
recursiveReplace(sb, ((Collection) o).toArray());
}
}
}
}
return sb;
}
protected String prepareSql(final String sql, final Object... bindObjects) {
return !sql.contains(inListReplace) ? sql : recursiveReplace(new StringBuilder(sql), bindObjects).toString();
}
@Override
public int executeUpdate(final String sql, final Object... bindObjects) throws SQLException {
return delegate.executeUpdate(prepareSql(sql, bindObjects), bindObjects);
}
@Override
public boolean executeUpdateSuccess(final String sql, final Object... bindObjects) throws SQLException {
return delegate.executeUpdateSuccess(prepareSql(sql, bindObjects), bindObjects);
}
@Override
public ResultSet toResultSet(String sql, Object... bindObjects) throws SQLException {
return delegate.toResultSet(prepareSql(sql, bindObjects), bindObjects);
}
@Override
public ResultSet toResultSet(String sql, PreparedStatementFactory psf, Object... bindObjects) throws SQLException {
return delegate.toResultSet(prepareSql(sql, bindObjects), psf, bindObjects);
}
@Override
public Long insertGetGeneratedKey(String sql, Object... bindObjects) throws SQLException {
return delegate.insertGetGeneratedKey(prepareSql(sql, bindObjects), bindObjects);
}
@Override
public <T> T insertGetGeneratedKeyType(String sql, TypeReference<T> typeReference, Object... bindObjects) throws SQLException {
return delegate.insertGetGeneratedKeyType(prepareSql(sql, bindObjects), typeReference, bindObjects);
}
@Override
public <T> T insertGetGeneratedKeyType(String sql, PreparedStatementFactory psf, TypeReference<T> typeReference, Object... bindObjects) throws SQLException {
return delegate.insertGetGeneratedKeyType(prepareSql(sql, bindObjects), psf, typeReference, bindObjects);
}
// DO NOT EDIT BELOW THIS LINE, OR CHANGE THIS COMMENT, CODE AUTOMATICALLY GENERATED BY genQueryMapper.sh
@Override
public <T> T toObject(PreparedStatement ps, Class<T> componentType, final Object... bindObjects) throws SQLException {
return delegate.toObject(ps, componentType, bindObjects);
}
@Override
public <T> T toObject(String sql, Class<T> componentType, final Object... bindObjects) throws SQLException {
return delegate.toObject(prepareSql(sql, bindObjects), componentType, bindObjects);
}
@Override
public <T> ResultSetIterable<T> toResultSetIterable(PreparedStatement ps, Class<T> componentType, final Object... bindObjects) throws SQLException {
return delegate.toResultSetIterable(ps, componentType, bindObjects);
}
@Override
public <T> ResultSetIterable<T> toResultSetIterable(String sql, Class<T> componentType, final Object... bindObjects) throws SQLException {
return delegate.toResultSetIterable(prepareSql(sql, bindObjects), componentType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> ResultSetIterable<Map<String, V>> toResultSetIterable(PreparedStatement ps, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toResultSetIterable(ps, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> ResultSetIterable<Map<String, V>> toResultSetIterable(String sql, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toResultSetIterable(prepareSql(sql, bindObjects), componentType, mapValType, bindObjects);
}
//IFJAVA8_START
@Override
public <T> Stream<T> toStream(PreparedStatement ps, Class<T> componentType, final Object... bindObjects) throws SQLException {
return delegate.toStream(ps, componentType, bindObjects);
}
@Override
public <T> Stream<T> toStream(String sql, Class<T> componentType, final Object... bindObjects) throws SQLException {
return delegate.toStream(prepareSql(sql, bindObjects), componentType, bindObjects);
}
//IFJAVA8_END
//IFJAVA8_START
@Override
public <T extends Map<String, V>, V> Stream<Map<String, V>> toStream(PreparedStatement ps, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toStream(ps, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Stream<Map<String, V>> toStream(String sql, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toStream(prepareSql(sql, bindObjects), componentType, mapValType, bindObjects);
}
//IFJAVA8_END
@Override
public <T extends Map<String, V>, V> Map<String, V> toSingleMap(PreparedStatement ps, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toSingleMap(ps, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Map<String, V> toSingleMap(String sql, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toSingleMap(prepareSql(sql, bindObjects), componentType, mapValType, bindObjects);
}
@Override
public <V> Map<String, V> toSingleMap(PreparedStatement ps, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toSingleMap(ps, mapValType, bindObjects);
}
@Override
public <V> Map<String, V> toSingleMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toSingleMap(prepareSql(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <T> T toType(PreparedStatement ps, TypeReference<T> typeReference, final Object... bindObjects) throws SQLException {
return delegate.toType(ps, typeReference, bindObjects);
}
@Override
public <T> T toType(String sql, TypeReference<T> typeReference, final Object... bindObjects) throws SQLException {
return delegate.toType(prepareSql(sql, bindObjects), typeReference, bindObjects);
}
@Override
public <T extends Collection<E>, E> T toCollection(PreparedStatement ps, final Class<T> collectionType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toCollection(ps, collectionType, componentType, bindObjects);
}
@Override
public <T extends Collection<E>, E> T toCollection(String sql, final Class<T> collectionType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toCollection(prepareSql(sql, bindObjects), collectionType, componentType, bindObjects);
}
@Override
public <T extends Collection<E>, E> T toCollection(PreparedStatement ps, T list, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toCollection(ps, list, componentType, bindObjects);
}
@Override
public <T extends Collection<E>, E> T toCollection(String sql, T list, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toCollection(prepareSql(sql, bindObjects), list, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E> T toMap(PreparedStatement ps, T map, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMap(ps, map, mapKeyType, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E> T toMap(String sql, T map, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMap(prepareSql(sql, bindObjects), map, mapKeyType, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(PreparedStatement ps, final Class<T> returnType, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollection(ps, returnType, mapKeyType, collectionType, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollection(prepareSql(sql, bindObjects), returnType, mapKeyType, collectionType, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(PreparedStatement ps, T map, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollection(ps, map, mapKeyType, collectionType, componentType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(String sql, T map, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollection(prepareSql(sql, bindObjects), map, mapKeyType, collectionType, componentType, bindObjects);
}
@Override
public <T> ListIterator<T> toListIterator(PreparedStatement ps, final Class<T> type, final Object... bindObjects) throws SQLException {
return delegate.toListIterator(ps, type, bindObjects);
}
@Override
public <T> ListIterator<T> toListIterator(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
return delegate.toListIterator(prepareSql(sql, bindObjects), type, bindObjects);
}
@Override
public <T> Iterator<T> toIterator(PreparedStatement ps, final Class<T> type, final Object... bindObjects) throws SQLException {
return delegate.toIterator(ps, type, bindObjects);
}
@Override
public <T> Iterator<T> toIterator(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
return delegate.toIterator(prepareSql(sql, bindObjects), type, bindObjects);
}
@Override
public <T> T[] toArray(PreparedStatement ps, final Class<T> type, final Object... bindObjects) throws SQLException {
return delegate.toArray(ps, type, bindObjects);
}
@Override
public <T> T[] toArray(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
return delegate.toArray(prepareSql(sql, bindObjects), type, bindObjects);
}
@Override
public <E> List<E> toList(PreparedStatement ps, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toList(ps, componentType, bindObjects);
}
@Override
public <E> List<E> toList(String sql, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toList(prepareSql(sql, bindObjects), componentType, bindObjects);
}
@Override
public <K, E> Map<K, E> toMap(PreparedStatement ps, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMap(ps, mapKeyType, componentType, bindObjects);
}
@Override
public <K, E> Map<K, E> toMap(String sql, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMap(prepareSql(sql, bindObjects), mapKeyType, componentType, bindObjects);
}
@Override
public <K, E extends List<C>, C> Map<K, E> toMapList(PreparedStatement ps, Class<K> mapKeyType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMapList(ps, mapKeyType, componentType, bindObjects);
}
@Override
public <K, E extends List<C>, C> Map<K, E> toMapList(String sql, Class<K> mapKeyType, Class<C> componentType, final Object... bindObjects) throws SQLException {
return delegate.toMapList(prepareSql(sql, bindObjects), mapKeyType, componentType, bindObjects);
}
@Override
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(PreparedStatement ps, final Class<T> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toCollectionMap(ps, collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(String sql, final Class<T> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toCollectionMap(prepareSql(sql, bindObjects), collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(PreparedStatement ps, T list, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toCollectionMap(ps, list, componentType, mapValType, bindObjects);
}
@Override
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(String sql, T list, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toCollectionMap(prepareSql(sql, bindObjects), list, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(PreparedStatement ps, final Class<T> returnType, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(ps, returnType, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(prepareSql(sql, bindObjects), returnType, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(PreparedStatement ps, T map, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(ps, map, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(String sql, T map, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(prepareSql(sql, bindObjects), map, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(PreparedStatement ps, final Class<T> returnType, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollectionMap(ps, returnType, mapKeyType, collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollectionMap(prepareSql(sql, bindObjects), returnType, mapKeyType, collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(PreparedStatement ps, T map, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollectionMap(ps, map, mapKeyType, collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(String sql, T map, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapCollectionMap(prepareSql(sql, bindObjects), map, mapKeyType, collectionType, componentType, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> ListIterator<Map<String, V>> toListIteratorMap(PreparedStatement ps, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListIteratorMap(ps, type, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> ListIterator<Map<String, V>> toListIteratorMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListIteratorMap(prepareSql(sql, bindObjects), type, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Iterator<Map<String, V>> toIteratorMap(PreparedStatement ps, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toIteratorMap(ps, type, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Iterator<Map<String, V>> toIteratorMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toIteratorMap(prepareSql(sql, bindObjects), type, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Map<String, V>[] toArrayMap(PreparedStatement ps, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toArrayMap(ps, type, mapValType, bindObjects);
}
@Override
public <T extends Map<String, V>, V> Map<String, V>[] toArrayMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toArrayMap(prepareSql(sql, bindObjects), type, mapValType, bindObjects);
}
@Override
public <E extends Map<String, V>, V> List<Map<String, V>> toListMap(PreparedStatement ps, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListMap(ps, componentType, mapValType, bindObjects);
}
@Override
public <E extends Map<String, V>, V> List<Map<String, V>> toListMap(String sql, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListMap(prepareSql(sql, bindObjects), componentType, mapValType, bindObjects);
}
@Override
public <K, E extends Map<String, V>, V> Map<K, Map<String, V>> toMapMap(PreparedStatement ps, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(ps, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <K, E extends Map<String, V>, V> Map<K, Map<String, V>> toMapMap(String sql, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(prepareSql(sql, bindObjects), mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <K, E extends Map<String, V>, V> Map<K, List<Map<String, V>>> toMapListMap(PreparedStatement ps, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapListMap(ps, mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <K, E extends Map<String, V>, V> Map<K, List<Map<String, V>>> toMapListMap(String sql, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapListMap(prepareSql(sql, bindObjects), mapKeyType, componentType, mapValType, bindObjects);
}
@Override
public <V> ListIterator<Map<String, V>> toListIteratorMap(PreparedStatement ps, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListIteratorMap(ps, mapValType, bindObjects);
}
@Override
public <V> ListIterator<Map<String, V>> toListIteratorMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListIteratorMap(prepareSql(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <V> Iterator<Map<String, V>> toIteratorMap(PreparedStatement ps, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toIteratorMap(ps, mapValType, bindObjects);
}
@Override
public <V> Iterator<Map<String, V>> toIteratorMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toIteratorMap(prepareSql(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <V> List<Map<String, V>> toListMap(PreparedStatement ps, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListMap(ps, mapValType, bindObjects);
}
@Override
public <V> List<Map<String, V>> toListMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toListMap(prepareSql(sql, bindObjects), mapValType, bindObjects);
}
@Override
public <K, V> Map<K, Map<String, V>> toMapMap(PreparedStatement ps, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(ps, mapKeyType, mapValType, bindObjects);
}
@Override
public <K, V> Map<K, Map<String, V>> toMapMap(String sql, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapMap(prepareSql(sql, bindObjects), mapKeyType, mapValType, bindObjects);
}
@Override
public <K, V> Map<K, List<Map<String, V>>> toMapListMap(PreparedStatement ps, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapListMap(ps, mapKeyType, mapValType, bindObjects);
}
@Override
public <K, V> Map<K, List<Map<String, V>>> toMapListMap(String sql, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
return delegate.toMapListMap(prepareSql(sql, bindObjects), mapKeyType, mapValType, bindObjects);
}
}

View File

@ -145,6 +145,26 @@ public class NullQueryMapper extends QueryMapper {
return of(qm, safeHandler);
}
@Override
public <T> InList.InListObject inList(String columnName, Collection<T> values) {
try {
return delegate.inList(columnName, values);
} catch (Throwable e) {
handler.handle(e);
}
return null;
}
@Override
public <T> InList.InListObject notInList(String columnName, Collection<T> values) {
try {
return delegate.notInList(columnName, values);
} catch (Throwable e) {
handler.handle(e);
}
return null;
}
// these update the database
@Override

View File

@ -6,6 +6,7 @@ import com.moparisthebest.jdbc.util.ResultSetIterable;
import com.moparisthebest.jdbc.util.ResultSetUtil;
import java.io.*;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.sql.*;
import java.util.*;
@ -54,11 +55,51 @@ public class QueryMapper implements JdbcMapper {
private static final Charset UTF_8 = Charset.forName("UTF-8");
IFJAVA6_END*/
protected static final InList defaultInList = getDefaultInList();
private static InList getDefaultInList() {
try {
final String inListClassName = System.getProperty("QueryMapper.defaultInList.class");
if(inListClassName != null) {
final Class<?> inListClass = Class.forName(inListClassName);
final Method method = inListClass.getMethod(System.getProperty("QueryMapper.defaultInList.method", "instance"));
return (InList) method.invoke(null);
} else {
// todo: change default to OPTIMAL ?
final String type = System.getProperty("queryMapper.databaseType", System.getProperty("jdbcMapper.databaseType", "BIND"));
if(type.equals("OPTIMAL")) {
return OptimalInList.instance();
} else {
switch (JdbcMapper.DatabaseType.valueOf(type)) {
case DEFAULT:
case BIND:
return BindInList.instance();
case ANY:
return ArrayInList.instance();
case ORACLE:
return OracleArrayInList.instance();
case UNNEST:
return UnNestArrayInList.instance();
default:
throw new RuntimeException("Invalid queryMapper.databaseType: " + type);
}
}
}
} catch (Throwable e) {
// NEVER ignore
throw new RuntimeException(e);
}
}
protected final ResultSetMapper cm;
protected final Connection conn;
protected final boolean closeConn;
protected QueryMapper(Connection conn, final String jndiName, Factory<Connection> factory, final ResultSetMapper cm) {
protected boolean inListEnabled = false;
protected final InList inList;
public static final String inListReplace = "{inList}";
protected QueryMapper(Connection conn, final String jndiName, Factory<Connection> factory, final ResultSetMapper cm, final InList inList) {
this.cm = cm == null ? defaultRsm : cm;
boolean closeConn = false;
if(conn == null) {
@ -76,9 +117,15 @@ public class QueryMapper implements JdbcMapper {
if (conn == null)
throw new NullPointerException("Connection needs to be non-null for QueryMapper...");
this.conn = conn;
this.inList = inList.instance(conn);
this.closeConn = closeConn;
}
protected QueryMapper(Connection conn, final String jndiName, Factory<Connection> factory, final ResultSetMapper cm) {
this(conn, jndiName, factory, cm, defaultInList);
}
public QueryMapper(Connection conn, ResultSetMapper cm) {
this(conn, null, null, cm);
}
@ -110,6 +157,7 @@ public class QueryMapper implements JdbcMapper {
this.cm = null;
this.conn = null;
this.closeConn = false;
this.inList = defaultInList;
}
@Override
@ -168,6 +216,51 @@ public class QueryMapper implements JdbcMapper {
return new BlobString(s, charset == null ? UTF_8 : charset);
}
// start in list specific code
protected PreparedStatement getPreparedStatement(final String sql, final Object... bindObjects) throws SQLException {
return getPreparedStatement(sql, defaultPsf, bindObjects);
}
protected PreparedStatement getPreparedStatement(final String sql, final PreparedStatementFactory psf, final Object... bindObjects) throws SQLException {
return psf.prepareStatement(conn, prepareInListSql(sql, bindObjects));
}
private static StringBuilder recursiveReplace(final StringBuilder sb, final Object... bindObjects) {
if (bindObjects != null && bindObjects.length > 0) {
for (Object o : bindObjects) {
if (o != null && o != QueryMapper.noBind) {
if (o instanceof InList.InListObject) {
final int startIndex = sb.indexOf(inListReplace);
if (startIndex < -1)
return sb; // we've replaced all, maybe an error? meh
sb.replace(startIndex, startIndex + inListReplace.length(), o.toString());
} else if (o instanceof Object[]) {
recursiveReplace(sb, (Object[]) o);
} else if (o instanceof Collection) {
recursiveReplace(sb, ((Collection) o).toArray());
}
}
}
}
return sb;
}
protected String prepareInListSql(final String sql, final Object... bindObjects) {
return inListEnabled && sql.contains(inListReplace) ? recursiveReplace(new StringBuilder(sql), bindObjects).toString() : sql;
}
public <T> InList.InListObject inList(final String columnName, final Collection<T> values) throws SQLException {
this.inListEnabled = true; // worth checking if it's already this or not?
return this.inList.inList(conn, columnName, values);
}
public <T> InList.InListObject notInList(final String columnName, final Collection<T> values) throws SQLException {
this.inListEnabled = true; // worth checking if it's already this or not?
return this.inList.notInList(conn, columnName, values);
}
// end in list specific code
public static void setObject(final PreparedStatement ps, final int index, final Object o) throws SQLException {
// we are going to put most common ones up top so it should execute faster normally
if (o == null || o instanceof String || o instanceof Number)
@ -340,7 +433,7 @@ public class QueryMapper implements JdbcMapper {
public int executeUpdate(String sql, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.executeUpdate(ps, bindObjects);
} finally {
tryClose(ps);
@ -350,7 +443,7 @@ public class QueryMapper implements JdbcMapper {
public boolean executeUpdateSuccess(String sql, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.executeUpdateSuccess(ps, bindObjects);
} finally {
tryClose(ps);
@ -469,7 +562,7 @@ public class QueryMapper implements JdbcMapper {
ResultSet rs = null;
T ret = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
rs = this.toResultSet(ps, bindObjects);
ret = cm.toType(rs, typeReference);
if(ret instanceof ResultSetIterable) {
@ -514,7 +607,7 @@ public class QueryMapper implements JdbcMapper {
ResultSet rs = null;
ResultSetIterable<T> ret = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
rs = this.toResultSet(ps, bindObjects);
ret = cm.toResultSetIterable(rs, componentType).setPreparedStatementToClose(ps);
error = false;
@ -534,7 +627,7 @@ public class QueryMapper implements JdbcMapper {
ResultSet rs = null;
ResultSetIterable<Map<String, V>> ret = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
rs = this.toResultSet(ps, bindObjects);
ret = cm.toResultSetIterable(rs, componentType, mapValType).setPreparedStatementToClose(ps);
error = false;
@ -555,7 +648,7 @@ public class QueryMapper implements JdbcMapper {
ResultSet rs = null;
Stream<T> ret = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
rs = this.toResultSet(ps, bindObjects);
final PreparedStatement finalPs = ps;
ret = cm.toStream(rs, componentType).onClose(() -> tryClose(finalPs));
@ -576,7 +669,7 @@ public class QueryMapper implements JdbcMapper {
ResultSet rs = null;
Stream<Map<String, V>> ret = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
rs = this.toResultSet(ps, bindObjects);
final PreparedStatement finalPs = ps;
ret = cm.toStream(rs, componentType, mapValType).onClose(() -> tryClose(finalPs));
@ -611,7 +704,7 @@ public class QueryMapper implements JdbcMapper {
public <T> T toObject(String sql, Class<T> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toObject(ps, componentType, bindObjects);
} finally {
tryClose(ps);
@ -649,7 +742,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<String, V>, V> Map<String, V> toSingleMap(String sql, Class<T> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toSingleMap(ps, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -663,7 +756,7 @@ public class QueryMapper implements JdbcMapper {
public <V> Map<String, V> toSingleMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toSingleMap(ps, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -681,7 +774,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Collection<E>, E> T toCollection(String sql, final Class<T> collectionType, Class<E> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toCollection(ps, collectionType, componentType, bindObjects);
} finally {
tryClose(ps);
@ -695,7 +788,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Collection<E>, E> T toCollection(String sql, T list, Class<E> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toCollection(ps, list, componentType, bindObjects);
} finally {
tryClose(ps);
@ -709,7 +802,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<K, E>, K, E> T toMap(String sql, T map, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMap(ps, map, mapKeyType, componentType, bindObjects);
} finally {
tryClose(ps);
@ -723,7 +816,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapCollection(ps, returnType, mapKeyType, collectionType, componentType, bindObjects);
} finally {
tryClose(ps);
@ -737,7 +830,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<K, E>, K, E extends Collection<C>, C> T toMapCollection(String sql, T map, Class<K> mapKeyType, Class<E> collectionType, Class<C> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapCollection(ps, map, mapKeyType, collectionType, componentType, bindObjects);
} finally {
tryClose(ps);
@ -751,7 +844,7 @@ public class QueryMapper implements JdbcMapper {
public <T> ListIterator<T> toListIterator(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toListIterator(ps, type, bindObjects);
} finally {
tryClose(ps);
@ -765,7 +858,7 @@ public class QueryMapper implements JdbcMapper {
public <T> Iterator<T> toIterator(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toIterator(ps, type, bindObjects);
} finally {
tryClose(ps);
@ -779,7 +872,7 @@ public class QueryMapper implements JdbcMapper {
public <T> T[] toArray(String sql, final Class<T> type, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toArray(ps, type, bindObjects);
} finally {
tryClose(ps);
@ -793,7 +886,7 @@ public class QueryMapper implements JdbcMapper {
public <E> List<E> toList(String sql, Class<E> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toList(ps, componentType, bindObjects);
} finally {
tryClose(ps);
@ -807,7 +900,7 @@ public class QueryMapper implements JdbcMapper {
public <K, E> Map<K, E> toMap(String sql, Class<K> mapKeyType, Class<E> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMap(ps, mapKeyType, componentType, bindObjects);
} finally {
tryClose(ps);
@ -821,7 +914,7 @@ public class QueryMapper implements JdbcMapper {
public <K, E extends List<C>, C> Map<K, E> toMapList(String sql, Class<K> mapKeyType, Class<C> componentType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapList(ps, mapKeyType, componentType, bindObjects);
} finally {
tryClose(ps);
@ -835,7 +928,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(String sql, final Class<T> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toCollectionMap(ps, collectionType, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -849,7 +942,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Collection<E>, E extends Map<String, V>, V> T toCollectionMap(String sql, T list, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toCollectionMap(ps, list, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -863,7 +956,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapMap(ps, returnType, mapKeyType, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -877,7 +970,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<K, E>, K, E extends Map<String, V>, V> T toMapMap(String sql, T map, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapMap(ps, map, mapKeyType, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -891,7 +984,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(String sql, final Class<T> returnType, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapCollectionMap(ps, returnType, mapKeyType, collectionType, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -905,7 +998,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<K, C>, K, C extends Collection<E>, E extends Map<String, V>, V> T toMapCollectionMap(String sql, T map, Class<K> mapKeyType, Class<C> collectionType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapCollectionMap(ps, map, mapKeyType, collectionType, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -919,7 +1012,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<String, V>, V> ListIterator<Map<String, V>> toListIteratorMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toListIteratorMap(ps, type, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -933,7 +1026,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<String, V>, V> Iterator<Map<String, V>> toIteratorMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toIteratorMap(ps, type, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -947,7 +1040,7 @@ public class QueryMapper implements JdbcMapper {
public <T extends Map<String, V>, V> Map<String, V>[] toArrayMap(String sql, final Class<T> type, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toArrayMap(ps, type, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -961,7 +1054,7 @@ public class QueryMapper implements JdbcMapper {
public <E extends Map<String, V>, V> List<Map<String, V>> toListMap(String sql, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toListMap(ps, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -975,7 +1068,7 @@ public class QueryMapper implements JdbcMapper {
public <K, E extends Map<String, V>, V> Map<K, Map<String, V>> toMapMap(String sql, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapMap(ps, mapKeyType, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -989,7 +1082,7 @@ public class QueryMapper implements JdbcMapper {
public <K, E extends Map<String, V>, V> Map<K, List<Map<String, V>>> toMapListMap(String sql, Class<K> mapKeyType, Class<E> componentType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapListMap(ps, mapKeyType, componentType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -1003,7 +1096,7 @@ public class QueryMapper implements JdbcMapper {
public <V> ListIterator<Map<String, V>> toListIteratorMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toListIteratorMap(ps, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -1017,7 +1110,7 @@ public class QueryMapper implements JdbcMapper {
public <V> Iterator<Map<String, V>> toIteratorMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toIteratorMap(ps, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -1031,7 +1124,7 @@ public class QueryMapper implements JdbcMapper {
public <V> List<Map<String, V>> toListMap(String sql, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toListMap(ps, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -1045,7 +1138,7 @@ public class QueryMapper implements JdbcMapper {
public <K, V> Map<K, Map<String, V>> toMapMap(String sql, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapMap(ps, mapKeyType, mapValType, bindObjects);
} finally {
tryClose(ps);
@ -1059,7 +1152,7 @@ public class QueryMapper implements JdbcMapper {
public <K, V> Map<K, List<Map<String, V>>> toMapListMap(String sql, Class<K> mapKeyType, Class<V> mapValType, final Object... bindObjects) throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps = getPreparedStatement(sql, bindObjects);
return this.toMapListMap(ps, mapKeyType, mapValType, bindObjects);
} finally {
tryClose(ps);

View File

@ -467,7 +467,6 @@ public class QueryMapperTest {
if(!(qm instanceof QueryMapperQmDao))
return;
final QueryMapper qm = ((QueryMapperQmDao)this.qm).getQm();
try {
// auto increment stuff for getGeneratedKeys, how obnoxious are these subtle differences...
if (isWrapperFor(qm.getConnection(), classForName("org.sqlite.SQLiteConnection"))) {