jetbrick-orm/src/main/java/jetbrick/dao/orm/utils/PreparedStatementCreator.java
protected static PreparedStatement createByMap(Connection conn, String sql, Map<String, ?> parameters) throws SQLException {
        StringBuffer sb = new StringBuffer();
        List<Object> params = new ArrayList<Object>();

        Matcher m = namedParameterPattern.matcher(sql);
        while (m.find()) {
            String key = m.group(1);
            Object value = parameters.get(key);
            if (value == null) {
                params.add(null);
                m.appendReplacement(sb, "?");
            } else if (value instanceof Object[]) {
                Object[] array = (Object[]) value;
                if (array.length == 0) {
                    params.add(null);
                    m.appendReplacement(sb, "?");
                } else {
                    for (Object one : array) {
                        params.add(one);
                    }
                    m.appendReplacement(sb, StringUtils.repeat("?", ",", array.length));
                }
            } else if (value instanceof Collection) {
                Collection<?> collection = (Collection<?>) value;
                if (collection.size() == 0) {
                    params.add(null);
                    m.appendReplacement(sb, "?");
                } else {
                    for (Object one : collection) {
                        params.add(one);
                    }
                    m.appendReplacement(sb, StringUtils.repeat("?", ",", collection.size()));
                }
            } else {
                params.add(value);
                m.appendReplacement(sb, "?");
            }
        }
        m.appendTail(sb);

        return createByIterator(conn, sb.toString(), params.iterator());
    }
protected static PreparedStatement createByMap(Connection conn, String sql, Map<String, ?> parameters) throws SQLException {
        StringBuffer sb = new StringBuffer();
        List<Object> params = new ArrayList<Object>();

        Matcher m = namedParameterPattern.matcher(sql);
        while (m.find()) {
            String key = m.group(1);
            Object value = parameters.get(key);
            if (value == null) {
                params.add(null);
                m.appendReplacement(sb, "?");
            } else if (value instanceof Object[]) {
                Object[] array = (Object[]) value;
                if (array.length == 0) {
                    params.add(null);
                    m.appendReplacement(sb, "?");
                } else {
                    for (Object one : array) {
                        params.add(one);
                    }
                    m.appendReplacement(sb, StringUtils.repeat("?", ",", array.length));
                }
            } else if (value instanceof Collection) {
                Collection<?> collection = (Collection<?>) value;
                if (collection.size() == 0) {
                    params.add(null);
                    m.appendReplacement(sb, "?");
                } else {
                    for (Object one : collection) {
                        params.add(one);
                    }
                    m.appendReplacement(sb, StringUtils.repeat("?", ",", collection.size()));
                }
            } else {
                params.add(value);
                m.appendReplacement(sb, "?");
            }
        }
        m.appendTail(sb);

        return createByIterator(conn, sb.toString(), params.iterator());
    }
protected static PreparedStatement createByMap ( Connection conn , String sql , Map < String , ? > parameters ) throws SQLException { StringBuffer sb = new StringBuffer ( ) ; List < Object > params = new ArrayList < Object > ( ) ; Matcher m = namedParameterPattern . matcher ( sql ) ; while ( m . find ( ) ) { String key = m . group ( 1 ) ; Object value = parameters . get ( key ) ; if ( value == null ) { params . add ( null ) ; m . appendReplacement ( sb , "?" ) ; } else if ( value instanceof Object [ ] ) { Object [ ] array = ( Object [ ] ) value ; if ( array . length == 0 ) { params . add ( null ) ; m . appendReplacement ( sb , "?" ) ; } else { for ( Object one : array ) { params . add ( one ) ; } m . appendReplacement ( sb , StringUtils . repeat ( "?" , "," , array . length ) ) ; } } else if ( value instanceof Collection ) { Collection < ? > collection = ( Collection < ? > ) value ; if ( collection . size ( ) == 0 ) { params . add ( null ) ; m . appendReplacement ( sb , "?" ) ; } else { for ( Object one : collection ) { params . add ( one ) ; } m . appendReplacement ( sb , StringUtils . repeat ( "?" , "," , collection . size ( ) ) ) ; } } else { params . add ( value ) ; m . appendReplacement ( sb , "?" ) ; } } m . appendTail ( sb ) ; return createByIterator ( conn , sb . toString ( ) , params . iterator ( ) ) ; }
Support :name as parameter, and Array or Collection type
Support : name as parameter and Array or Collection type