Search code examples
javaoracle-databasestored-proceduresspring-jdbcsynonym

Spring SimpleJdbcCall and Oracle Synonyms


After upgrading the Spring framework from <4.2.2.RELEASE> to <5.0.2.RELEASE> I can't call a stored procedure in my Oracle database using synonyms (SimpleJdbcCall). I noticed that as my code started to throw

Unable to determine the correct call signature - no procedure/function/signature for "name of my stored procedure"

exceptions. Then I debugged and found out that the stored procedure can't be found if it's behind a synonym. With the old Spring version that was not a problem. So what did they change and what can I do now? I read about retrieving the original Oracle connection from the Datasource and activating the synonym flag there: https://docs.oracle.com/cd/E11882_01/appdev.112/e13995/oracle/jdbc/OracleConnection.html#setIncludeSynonyms_boolean_

But that does not seem to me to be a "beautiful" solution...


Solution

  • Since I did not find any other solution, I switched from SimpleJdbcCall to the usual Spring JdbcTemplate and called my stored procedure with

    private jdbcTemplate = new JdbcTemplate(myDataSource);
    try{
      CallableStatement callableStatement = jdbcTemplate.getDataSource().getConnection().prepareCall("{call PACKAGE_NAME.STORED_PROCEDURE_NAME}");
      callableStatement.executeUpdate();
    } catch(SQLException e)
    {
    ...
    }
    

    That worked fine then.

    Update: The problem was fixed in Spring 5.0.4.RELEASE, consider https://jira.spring.io/browse/SPR-16478