diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java index 8e55573825..dae4f358cd 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java @@ -378,40 +378,12 @@ public class OracleStoredProcedureTest { ); } - @Test - public void testNamedNativeQueryStoredProcedureRefCursor(EntityManagerFactoryScope scope) { - scope.inTransaction( - entityManager -> { - try { - List postAndComments = entityManager - .createNamedQuery( - "fn_person_and_phones" ) - .setParameter( 1, 1L ) - .getResultList(); - Object[] postAndComment = postAndComments.get( 0 ); - Person person = (Person) postAndComment[0]; - Phone phone = (Phone) postAndComment[1]; - assertEquals( 2, postAndComments.size() ); - fail( "expected UnsupportedOperationException" ); - } - catch (IllegalArgumentException ex) { - assertThat( ex.getCause(), instanceOf( UnsupportedOperationException.class ) ); - assertEquals( - "Recognizing native query as a function call is no longer supported", - ex.getCause().getMessage() - ); - } - } - ); - } - @Test public void testNamedProcedureCallStoredProcedureRefCursor(EntityManagerFactoryScope scope) { scope.inTransaction( entityManager -> { List postAndComments = entityManager - .createNamedStoredProcedureQuery( - "fn_person_and_phones_sq" ) + .createNamedStoredProcedureQuery( "personAndPhonesFunction" ) .setParameter( 1, 1L ) .getResultList(); Object[] postAndComment = postAndComments.get( 0 ); @@ -423,7 +395,7 @@ public class OracleStoredProcedureTest { } @Test - public void testNamedNativeQueryStoredProcedureRefCursorWithJDBC(EntityManagerFactoryScope scope) { + public void testFunctionCallWithJdbc(EntityManagerFactoryScope scope) { scope.inTransaction( entityManager -> { Session session = entityManager.unwrap( Session.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java index d7f3c77c77..c2a9d8737b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java @@ -442,7 +442,7 @@ public class HANAStoredProcedureTest extends BaseEntityManagerFunctionalTestCase @Test @TestForIssue(jiraKey = "HHH-12138") - public void testNamedNativeQueryStoredProcedureRefCursorWithJDBC() { + public void testFunctionCallWithJDBC() { EntityManager entityManager = createEntityManager(); entityManager.getTransaction().begin(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/procedure/Person.java b/hibernate-core/src/test/java/org/hibernate/test/procedure/Person.java index ee95a5e460..e2c6100802 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/procedure/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/test/procedure/Person.java @@ -11,6 +11,7 @@ import java.util.Date; import java.util.List; import org.hibernate.annotations.NamedNativeQuery; +import org.hibernate.jpa.AvailableHints; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; @@ -34,30 +35,22 @@ import static org.hibernate.jpa.HibernateHints.HINT_CALLABLE_FUNCTION; /** * @author Vlad Mihalcea */ -@NamedNativeQuery( - name = "fn_person_and_phones", - query = "{ ? = call fn_person_and_phones( ? ) }", - callable = true, - resultSetMapping = "person_with_phones" +@NamedStoredProcedureQuery( + name = "personAndPhonesFunction", + procedureName = "fn_person_and_phones", + resultSetMappings = "personWithPhonesMapping", + parameters = @StoredProcedureParameter(type = Long.class), + hints = @QueryHint(name = HINT_CALLABLE_FUNCTION, value = "true") ) @NamedNativeQuery( - name = "fn_person_and_phones_hana", - query = "select \"pr.id\", \"pr.name\", \"pr.nickName\", \"pr.address\", \"pr.createdOn\", \"pr.version\", \"ph.id\", \"ph.person_id\", \"ph.phone_number\", \"ph.valid\" from fn_person_and_phones( ? )", - callable = false, - resultSetMapping = "person_with_phones_hana" - ) -@NamedStoredProcedureQuery( - name = "fn_person_and_phones_sq", - procedureName = "fn_person_and_phones", - resultSetMappings = "person_with_phones", - parameters = { - @StoredProcedureParameter(type = Long.class) - }, - hints = @QueryHint(name = HINT_CALLABLE_FUNCTION, value = "true") + name = "fn_person_and_phones_hana", + query = "select \"pr.id\", \"pr.name\", \"pr.nickName\", \"pr.address\", \"pr.createdOn\", \"pr.version\", \"ph.id\", \"ph.person_id\", \"ph.phone_number\", \"ph.valid\" from fn_person_and_phones( ? )", + callable = false, + resultSetMapping = "person_with_phones_hana" ) @SqlResultSetMappings({ @SqlResultSetMapping( - name = "person_with_phones", + name = "personWithPhonesMapping", entities = { @EntityResult( entityClass = Person.class,