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

Passing null as parameter is not allowed even when enablePassingNulls() has been called

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.3.0.Final, 5.3.1, 5.3.2, 5.3.3, 5.3.4
    • Fix Version/s: 5.3.5, 5.4
    • Component/s: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      I have set the enablePassingNulls to 'true', but it has thrown an Exception.

      public class StoredProcedureParameterTypeTest extends BaseNonConfigCoreFunctionalTestCase {
      ...
          @Test
          @TestForIssue( jiraKey = "HHH-12905" )
          public void testStringTypeInParameterIsNull() {
              inTransaction(
                      session -> {
      						ProcedureCall procedureCall = session.createStoredProcedureCall("test");
      						procedureCall.registerParameter(1, StringType.class, ParameterMode.IN).enablePassingNulls(true);
      						procedureCall.setParameter(1, null);
      				}
              );
          }
      }
      
      Bind value [null] was not of specified type [class org.hibernate.type.StringType
      java.lang.IllegalArgumentException: Bind value [null] was not of specified type [class org.hibernate.type.StringType
      	at org.hibernate.procedure.internal.ParameterBindImpl.internalSetValue(ParameterBindImpl.java:83)
      	at org.hibernate.procedure.internal.ParameterBindImpl.setBindValue(ParameterBindImpl.java:64)
      	at org.hibernate.procedure.internal.ProcedureCallImpl.setParameter(ProcedureCallImpl.java:824)
      	at org.hibernate.procedure.internal.ProcedureCallImpl.setParameter(ProcedureCallImpl.java:70)
      	at org.hibernate.test.procedure.StoredProcedureParameterTypeTest.lambda$testStringTypeInParameterIsNull$31(StoredProcedureParameterTypeTest.java:370)
      	at org.hibernate.testing.transaction.TransactionUtil2.inTransaction(TransactionUtil2.java:57)
      	at org.hibernate.testing.transaction.TransactionUtil2.lambda$inTransaction$0(TransactionUtil2.java:44)
      	at org.hibernate.testing.transaction.TransactionUtil2.inSession(TransactionUtil2.java:29)
      	at org.hibernate.testing.transaction.TransactionUtil2.inTransaction(TransactionUtil2.java:41)
      	at org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase.inTransaction(BaseNonConfigCoreFunctionalTestCase.java:560)
      	at org.hibernate.test.procedure.StoredProcedureParameterTypeTest.testStringTypeInParameterIsNull(StoredProcedureParameterTypeTest.java:366)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.lang.Thread.run(Thread.java:745)
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: