Search in sources :

Example 1 with NamedParameter

use of org.simpleflatmapper.jdbc.named.NamedParameter in project SimpleFlatMapper by arnaudroger.

the class SqlParameterSourceBuilder method buildFactory.

@SuppressWarnings("unchecked")
public SqlParameterSourceFactory<T> buildFactory(String sql) {
    NamedSqlQuery namedSqlQuery = NamedSqlQuery.parse(sql);
    for (int i = 0; i < namedSqlQuery.getParametersSize(); i++) {
        NamedParameter parameter = namedSqlQuery.getParameter(i);
        add(parameter.getName());
    }
    return buildFactory();
}
Also used : NamedParameter(org.simpleflatmapper.jdbc.named.NamedParameter) NamedSqlQuery(org.simpleflatmapper.jdbc.named.NamedSqlQuery)

Example 2 with NamedParameter

use of org.simpleflatmapper.jdbc.named.NamedParameter in project SimpleFlatMapper by arnaudroger.

the class MappingSqlQuery method extractParameters.

private SqlParameter[] extractParameters(String sql) {
    NamedSqlQuery query = NamedSqlQuery.parse(sql);
    SqlParameter[] params = new SqlParameter[query.getParametersSize()];
    for (int i = 0; i < params.length; i++) {
        NamedParameter namedParameter = query.getParameter(i);
        params[i] = new SqlParameter(namedParameter.getName(), 0);
    }
    return params;
}
Also used : SqlParameter(org.springframework.jdbc.core.SqlParameter) NamedParameter(org.simpleflatmapper.jdbc.named.NamedParameter) NamedSqlQuery(org.simpleflatmapper.jdbc.named.NamedSqlQuery)

Aggregations

NamedParameter (org.simpleflatmapper.jdbc.named.NamedParameter)2 NamedSqlQuery (org.simpleflatmapper.jdbc.named.NamedSqlQuery)2 SqlParameter (org.springframework.jdbc.core.SqlParameter)1