/** * Finds SQL for a named fragment key. * <p> * This finds, processes and returns a named block from the bundle. * * @param name the name, not null * @param params the Spring SQL parameters, not null * @return the SQL, not null * @throws IllegalArgumentException if there is no fragment with the specified name * @throws RuntimeException if a problem occurs */ String getSql(String name, SqlParams params) { if (name == null) { throw new IllegalArgumentException("Fragment name must not be null"); } if (params == null) { throw new IllegalArgumentException("SqlParams must not be null"); } NameSqlFragment fragment = getFragment(name); StringBuilder buf = new StringBuilder(1024); fragment.toSQL(buf, this, params, NO_LOOP); return buf.toString(); }
@Override void toSQL(StringBuilder buf, SqlFragments fragments, SqlParams params, int[] loopIndex) { String key = _includeKey; if (key.startsWith(":")) { String var = extractVariableName(key); if (params.contains(var)) { key = params.get(var).toString(); } } NameSqlFragment unit = fragments.getFragment(key); unit.toSQL(buf, fragments, params, loopIndex); }