I tried to call a stored procedure query with hibernate type and parameter with Hibernate ORM 5.3.0.Final, then I got an IllegalArgumentException. Example code: {code:java} package com.example;
import org.hibernate.Session; import org.hibernate.dialect.H2Dialect; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.hibernate.type.NumericBooleanType; import org.hibernate.type.YesNoType; import org.junit.After; import org.junit.Before; import org.junit.Test;
import javax.persistence.ParameterMode;
@RequiresDialect(H2Dialect.class) public class StoredProcedureApiTest extends BaseNonConfigCoreFunctionalTestCase {
private Session session;
@Before public void setUp() { session = openSession(); }
@After public void tearDown() { session.close(); }
@Test public void testNumericBooleanTypeInParameter() { session.createStoredProcedureQuery("test") .registerStoredProcedureParameter(1, NumericBooleanType.class, ParameterMode.IN) .registerStoredProcedureParameter(2, String.class, ParameterMode.OUT) .setParameter(1, false); }
@Test public void testYesNoTypeInParameter() { session.createStoredProcedureQuery("test") .registerStoredProcedureParameter(1, YesNoType.class, ParameterMode.IN) .registerStoredProcedureParameter(2, String.class, ParameterMode.OUT) .setParameter(1, false); }
} {code} Exceptions:
{code:java} **java.lang.IllegalArgumentException: Bind value [false] was not of specified type [class org.hibernate.type.NumericBooleanType** 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:818) at org.hibernate.procedure.internal.ProcedureCallImpl.setParameter(ProcedureCallImpl.java:70) {code}
{code:java} java.lang.IllegalArgumentException: Bind value [false] was not of specified type [class org.hibernate.type.YesNoType 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:818) at org.hibernate.procedure.internal.ProcedureCallImpl.setParameter(ProcedureCallImpl.java:70) {code}
|
|