Uploaded image for project: 'Hibernate ORM'
  1. HHH-10752

ProcedureCallImpl registers every paremeter twice

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.0
    • Fix Version/s: 5.2.0
    • Component/s: None
    • Labels:
      None
    • Last commented by a user?:
      true

      Description

      Now that stored procedure tests have been added, I noticed that on 5.2.0 neither one of the REFCURSOR tests works anymore.

      To replicate it, first set up tests to run on PostgreSQL:

      > gradle clean testClasses -Pdb=pgsql
      

      Then run the org.hibernate.test.procedure.PostgreSQLStoredProcedureTest#testStoredProcedureOutParameter test.

      You'll get the following error:

      javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults
      
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
      	at org.hibernate.procedure.internal.ProcedureCallImpl.execute(ProcedureCallImpl.java:643)
      	at org.hibernate.test.procedure.PostgreSQLStoredProcedureTest.testStoredProcedureOutParameter(PostgreSQLStoredProcedureTest.java:184)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      

      Because the input parameters are doubled:

      13:28:46,836 DEBUG SQL:92 - 
          {call sp_count_phones(?,?,?,?)}
      13:28:46,838 TRACE BasicBinder:65 - binding parameter [1] as [BIGINT] - [1]
      13:28:46,838 TRACE BasicBinder:65 - binding parameter [2] as [BIGINT] - [1]
      13:28:46,844  WARN SqlExceptionHelper:129 - SQL Error: 0, SQLState: 42883
      

      Even if there were only two registrations:

      StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "sp_count_phones" );
      query.registerStoredProcedureParameter( "personId", Long.class, ParameterMode.IN );
      query.registerStoredProcedureParameter( "phoneCount", Long.class, ParameterMode.OUT );
      
      query.setParameter( "personId", 1L );
      
      query.execute();
      Long phoneCount = (Long) query.getOutputParameterValue( "phoneCount" );
      

      Most likely, the issue comes from ProcedureCallImpl where in the registerStoredProcedureParameter method, the registerParameter method is called twice:

      registerParameter( (ParameterRegistrationImplementor) registerParameter( parameterName, type, mode ) );
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: