HHH-18280 - Support named procedure parameters down to the JDBC leve

This commit is contained in:
Steve Ebersole 2024-06-19 00:40:09 -05:00
parent e5b86f31f2
commit 5a111c8fbb
1 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate.orm.test.sql.storedproc; package org.hibernate.orm.test.sql.storedproc;
import java.sql.CallableStatement;
import java.util.List; import java.util.List;
import org.hibernate.boot.MetadataBuilder; import org.hibernate.boot.MetadataBuilder;
@ -15,10 +16,14 @@ import org.hibernate.procedure.ProcedureOutputs;
import org.hibernate.result.Output; import org.hibernate.result.Output;
import org.hibernate.result.ResultSetOutput; import org.hibernate.result.ResultSetOutput;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.RequiresDialect; import org.hibernate.testing.orm.junit.RequiresDialect;
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest; import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.ParameterMode;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.orm.junit.ExtraAssertions.assertTyping; import static org.hibernate.testing.orm.junit.ExtraAssertions.assertTyping;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -101,4 +106,18 @@ public class StoredProcedureTest extends BaseSessionFactoryFunctionalTest {
} }
} ); } );
} }
@Test
@FailureExpected( reason = "We currently expect the registrations to happen positionally", jiraKey = "HHH-18280" )
public void testNamedParameters() {
inTransaction( (session) -> {
final ProcedureCall findUserRange = session.createStoredProcedureCall( "findUserRange" );
findUserRange.registerParameter( "end", int.class, ParameterMode.IN );
findUserRange.registerParameter( "start", int.class, ParameterMode.IN );
findUserRange.setParameter( "start", 1 );
findUserRange.setParameter( "end", 10 );
final List<?> resultList = findUserRange.getResultList();
assertThat( resultList ).hasSize( 9 );
} );
}
} }