1 16 17 package org.springframework.jdbc.object; 18 19 import java.util.Map ; 20 21 import javax.sql.DataSource ; 22 23 import org.springframework.dao.DataAccessException; 24 import org.springframework.dao.InvalidDataAccessApiUsageException; 25 import org.springframework.jdbc.core.JdbcTemplate; 26 import org.springframework.jdbc.core.ParameterMapper; 27 import org.springframework.jdbc.core.SqlParameter; 28 29 44 public abstract class StoredProcedure extends SqlCall { 45 46 49 protected StoredProcedure() { 50 } 51 52 58 protected StoredProcedure(DataSource ds, String name) { 59 setDataSource(ds); 60 setSql(name); 61 } 62 63 68 protected StoredProcedure(JdbcTemplate jdbcTemplate, String name) { 69 setJdbcTemplate(jdbcTemplate); 70 setSql(name); 71 } 72 73 74 78 protected boolean allowsUnusedParameters() { 79 return true; 80 } 81 82 89 public void declareParameter(SqlParameter param) throws InvalidDataAccessApiUsageException { 90 if (param.getName() == null) { 91 throw new InvalidDataAccessApiUsageException("Parameters to stored procedures must have names as well as types"); 92 } 93 super.declareParameter(param); 94 } 95 96 97 111 public Map execute(Map inParams) throws DataAccessException { 112 validateParameters(inParams.values().toArray()); 113 return getJdbcTemplate().call(newCallableStatementCreator(inParams), getDeclaredParameters()); 114 } 115 116 132 public Map execute(ParameterMapper inParamMapper) throws DataAccessException { 133 checkCompiled(); 134 return getJdbcTemplate().call(newCallableStatementCreator(inParamMapper), getDeclaredParameters()); 135 } 136 137 } 138 | Popular Tags |