Example usage for org.springframework.jdbc.core SqlParameter getName

List of usage examples for org.springframework.jdbc.core SqlParameter getName

Introduction

In this page you can find the example usage for org.springframework.jdbc.core SqlParameter getName.

Prototype

@Nullable
public String getName() 

Source Link

Document

Return the name of the parameter, or null if anonymous.

Usage

From source file:org.springframework.jdbc.core.simple.AbstractJdbcCall.java

/**
 * Delegate method to perform the actual call processing.
 *///from   w  w w  .  ja  va2s.  co  m
private Map<String, Object> executeCallInternal(Map<String, ?> args) {
    CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(args);
    if (logger.isDebugEnabled()) {
        logger.debug("The following parameters are used for call " + getCallString() + " with " + args);
        int i = 1;
        for (SqlParameter param : getCallParameters()) {
            logger.debug(i + ": " + param.getName() + ", SQL type " + param.getSqlType() + ", type name "
                    + param.getTypeName() + ", parameter class [" + param.getClass().getName() + "]");
            i++;
        }
    }
    return getJdbcTemplate().call(csc, getCallParameters());
}

From source file:org.springframework.jdbc.object.RdbmsOperation.java

/**
 * Validate the named parameters passed to an execute method based on declared parameters.
 * Subclasses should invoke this method before every {@code executeQuery()} or
 * {@code update()} method./*from  ww w  .ja  va2 s .c o m*/
 * @param parameters parameter Map supplied (may be {@code null})
 * @throws InvalidDataAccessApiUsageException if the parameters are invalid
 */
protected void validateNamedParameters(@Nullable Map<String, ?> parameters)
        throws InvalidDataAccessApiUsageException {
    checkCompiled();
    Map<String, ?> paramsToUse = (parameters != null ? parameters : Collections.<String, Object>emptyMap());
    int declaredInParameters = 0;
    for (SqlParameter param : this.declaredParameters) {
        if (param.isInputValueProvided()) {
            if (!supportsLobParameters()
                    && (param.getSqlType() == Types.BLOB || param.getSqlType() == Types.CLOB)) {
                throw new InvalidDataAccessApiUsageException(
                        "BLOB or CLOB parameters are not allowed for this kind of operation");
            }
            if (param.getName() != null && !paramsToUse.containsKey(param.getName())) {
                throw new InvalidDataAccessApiUsageException("The parameter named '" + param.getName()
                        + "' was not among the parameters supplied: " + paramsToUse.keySet());
            }
            declaredInParameters++;
        }
    }
    validateParameterCount(paramsToUse.size(), declaredInParameters);
}