Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-13669

SimpleJdbcCall does not throw an Exception for a missing stored procedure if the name does not contain "."

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.0.9, 4.2.2
    • Fix Version/s: 4.2.3
    • Component/s: Data:JDBC
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      Try these with an empty (for example in memory, derby) database:

      new SimpleJdbcCall(jdbcTemplate).withProcedureName("bar").compile();
      
      new SimpleJdbcCall(jdbcTemplate).withProcedureName("foo.bar").compile();
      

      The first one passes but the second one throws an exception (below). I think both should throw an exception (as there are no stored procedures with those names in the database).

      The issue seems to be in GenericCallMetaDataProvider.processProcedureColumns() (code is the same in 4.0.x and master branches). It throws an exception in case more than one sprocs are found and also in case no sproc was found and the name contains a "."
      It seems it is missing an else branch to throw an exception for other not found sprocs as well.

      org.springframework.dao.InvalidDataAccessApiUsageException: Unable to determine the correct call signature for FOO.BAR - package name should be specified separately using '.withCatalogName("FOO")'
      	at org.springframework.jdbc.core.metadata.GenericCallMetaDataProvider.processProcedureColumns(GenericCallMetaDataProvider.java:328)
      	at org.springframework.jdbc.core.metadata.GenericCallMetaDataProvider.initializeWithProcedureColumnMetaData(GenericCallMetaDataProvider.java:104)
      	at org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory$1.processMetaData(CallMetaDataProviderFactory.java:128)
      	at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:290)
      	at org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory.createMetaDataProvider(CallMetaDataProviderFactory.java:71)
      	at org.springframework.jdbc.core.metadata.CallMetaDataContext.initializeMetaData(CallMetaDataContext.java:269)
      	at org.springframework.jdbc.core.simple.AbstractJdbcCall.compileInternal(AbstractJdbcCall.java:279)
      	at org.springframework.jdbc.core.simple.AbstractJdbcCall.compile(AbstractJdbcCall.java:266)
      

      The reason why it would be good to have an early exception is to catch missing stored procedures during application startup (when the SimpleJdbcCall is created and compiled) instead only when it is used (sproc is called).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                akiraly Attila Király
                Last updater:
                Juergen Hoeller
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 1 week, 6 days ago