Example usage for org.springframework.jdbc.core CallableStatementCreatorFactory newCallableStatementCreator

List of usage examples for org.springframework.jdbc.core CallableStatementCreatorFactory newCallableStatementCreator

Introduction

In this page you can find the example usage for org.springframework.jdbc.core CallableStatementCreatorFactory newCallableStatementCreator.

Prototype

public CallableStatementCreator newCallableStatementCreator(ParameterMapper inParamMapper) 

Source Link

Document

Return a new CallableStatementCreator instance given this parameter mapper.

Usage

From source file:architecture.ee.jdbc.sqlquery.factory.impl.SqlQueryImpl.java

public Object call(String statement, Object... parameters) {
    BoundSql sql = getBoundSql(statement);

    List<SqlParameter> declaredParameters = new ArrayList<SqlParameter>();
    Map<String, Object> paramsToUse = new HashMap<String, Object>();

    //  ?? ? INPUT  OUTPU ? .

    for (ParameterMapping mapping : sql.getParameterMappings()) {

        mapping.getProperty();/*from w  w w . ja va  2 s  . c om*/
        mapping.getJdbcType();
        mapping.getMode();

        if (mapping.getMode() == ParameterMapping.Mode.IN) {

            SqlParameter input = new SqlParameter(mapping.getProperty(), mapping.getJdbcType().ordinal());
            declaredParameters.add(input);
            paramsToUse.put(mapping.getProperty(), parameters[mapping.getIndex() - 1]);

        } else if (mapping.getMode() == ParameterMapping.Mode.OUT) {
            SqlOutParameter output = new SqlOutParameter(mapping.getProperty(),
                    mapping.getJdbcType().ordinal());
            declaredParameters.add(output);
        }
    }

    CallableStatementCreatorFactory callableStatementFactory = new CallableStatementCreatorFactory(sql.getSql(),
            declaredParameters);
    return jdbcTemplate.call(callableStatementFactory.newCallableStatementCreator(paramsToUse),
            declaredParameters);

}