title: spring jdbc : simplejdbcall doesn't read metadata for parameters when executing stored procedure using synonym
body: <p>I am trying to execute a stored procedure using simpleJDBCCall.excute(in) method but it doesn't read the metadata in case of using synonym for the procedure. </p>
  
  <p>Here is the code. </p>
  
  <pre><code>SimpleJdbcCall optOutCall = new SimpleJdbcCall(dataSource)
          .withSchemaName("USER_SCH")
          .withCatalogName("USER")
          .withProcedureName(ADD_ADDRESS) 
          .declareParameters(
                  new SqlOutParameter("returnCode", Types.NUMERIC),
                  new SqlParameter("product_id", Types.NUMERIC),
                  new SqlParameter("user_id", Types.NUMERIC),
                  new SqlParameter("email_address", Types.VARCHAR));
      long returnCode = 0;
      inputs.addValue("returnCode", returnCode);
      inputs.addValue("product_id", 1);
      inputs.addValue("user_id", 45673);
      inputs.addValue("email_address", "a.b@abc.com");
  
      optOutCall.execute(inputs);
  </code></pre>
  
  <p>Here "<strong><em>ADD_ADDRESS</em></strong>" procedure exist under "<strong><em>USER</em></strong>" package in a schema called "<strong><em>USER_DATA</em></strong>". I have created a synonym for the same package/procedure in another schema called "<strong><em>USER_SCH</em></strong>". when i execute the code using simpleJDBCCall.execute() method it doesn't read the metatadata and throws the following execption.</p>
  
  <pre><code>    Caused by: java.sql.SQLException: ORA-06550: line 1, column 7:PLS-00306: wrong number or types of arguments in call to 'ADD_ADDRESS'ORA-06550: line 1, column 7:PL/SQL: Statement ignored
  </code></pre>
  
  <p>Here are the log messages. </p>
  
  <pre><code>[07 Oct 2014 10:32:49,019] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [JdbcCall call not compiled before execution - invoking compile]
  [07 Oct 2014 10:32:49,019] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Fetching JDBC Connection from DataSource]
  [07 Oct 2014 10:32:49,020] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory]: [Using org.springframework.jdbc.core.metadata.OracleCallMetaDataProvider]
  [07 Oct 2014 10:32:49,020] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataProvider]: [Retrieving metadata for USER/USER_SCH/ADD_ADDRESS]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Returning JDBC Connection to DataSource]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [Compiled stored procedure. Call string is [{call USER.ADD_ADDRESS()}]]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [SqlCall for procedure [ADD_ADDRESS] compiled]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataContext]: [Matching [returnCode, product_id, user_id,email_address] with []]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataContext]: [Found match for []]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [The following parameters are used for call {call USER.ADD_ADDRESS()} with: {}]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.JdbcTemplate]: [Calling stored procedure [{call USER.ADD_ADDRESS()}]]
  [07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Fetching JDBC Connection from DataSource]
  [07 Oct 2014 10:32:49,034] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Returning JDBC Connection to DataSource]
  [07 Oct 2014 10:32:49,034] [DEBUG] [org.springframework.jdbc.support.SQLErrorCodesFactory]: [Looking up default SQLErrorCodes for DataSource [weblogic.jdbc.common.internal.RmiDataSource@2521ddb8]]
  [07 Oct 2014 10:32:49,034] [DEBUG] [org.springframework.jdbc.support.SQLErrorCodesFactory]: [SQLErrorCodes found in cache for DataSource [weblogic.jdbc.common.internal.RmiDataSource@2521ddb8]]
  [07 Oct 2014 10:32:49,035] [DEBUG] [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator]: [Unable to translate SQLException with Error code '6550', will now try the fallback translator]
  [07 Oct 2014 10:32:49,035] [DEBUG] [org.springframework.jdbc.support.SQLStateSQLExceptionTranslator]: [Extracted SQL state class '65' from value '65000']
  [07 Oct 2014 10:32:49,035] [ WARN] [gproducterr]: [Handler execution resulted in exception]
  org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call USER.ADD_ADDRESS()}]; nested exception is java.sql.SQLException: ORA-06550: line 1, column 7:
  PLS-00306: wrong number or types of arguments in call to 'ADD_ADDRESS'ORA-06550: line 1, column :PL/SQL: Statement ignored
  </code></pre>
  
  <p>But if i execute the same code with schema name "USER_DATA" where this procedure "USER.ADD_ADDRESS" exists then it reads the metadata information correctly and executes the procedure. </p>
  
  <p>user that i am using has the execute permissions for "USER_SCH.USER.ADD_ADDRESS" procedure. </p>
  
  <p>what change do i need to make to read the metadata correctly when executing any procedure using synonyms??</p>