diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/HibernateHints.java b/hibernate-core/src/main/java/org/hibernate/jpa/HibernateHints.java index 566d8e179473..537964225dc5 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/HibernateHints.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/HibernateHints.java @@ -151,10 +151,33 @@ public interface HibernateHints { /** * Whether to treat a {@link org.hibernate.procedure.ProcedureCall} * or {@link jakarta.persistence.StoredProcedureQuery} as a call - * to a function rather than a call to a procedure. + * to a function rather than a call to a procedure. Set hint to + * {@link Boolean#TRUE TRUE} or {@code "true"} to indicated that + * the call should be treated as a function call. + *

+ * When no other return type is indicated, a function is assumed + * to return {@link java.sql.Types#REF_CURSOR REF_CURSOR}. + * + * @see org.hibernate.procedure.ProcedureCall#markAsFunctionCall + * @see #HINT_CALLABLE_FUNCTION_RETURN_TYPE */ String HINT_CALLABLE_FUNCTION = "org.hibernate.callableFunction"; + /** + * The {@linkplain org.hibernate.type.SqlTypes JDBC type code}, + * {@linkplain org.hibernate.query.BindableType type}, or + * {@link Class} of the value returned by a SQL function called + * via {@link org.hibernate.procedure.ProcedureCall} or + * {@link jakarta.persistence.StoredProcedureQuery}. Has the side + * effect of causing the call to be treated as a function call + * rather than a call to a stored procedure. + * + * @see org.hibernate.procedure.ProcedureCall#markAsFunctionCall(int) + * @see org.hibernate.procedure.ProcedureCall#markAsFunctionCall(org.hibernate.query.BindableType) + * @see org.hibernate.procedure.ProcedureCall#markAsFunctionCall(Class) + */ + String HINT_CALLABLE_FUNCTION_RETURN_TYPE = "hibernate.procedure.function_return_jdbc_type_code"; + /** * Hint for specifying the tenant id to use when creating an * {@link jakarta.persistence.EntityManagerFactory#createEntityManager(java.util.Map) EntityManager}. diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/FunctionReturn.java b/hibernate-core/src/main/java/org/hibernate/procedure/FunctionReturn.java index f851047d917c..0f0f21ff3c96 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/FunctionReturn.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/FunctionReturn.java @@ -4,14 +4,23 @@ */ package org.hibernate.procedure; +import org.hibernate.Incubating; import org.hibernate.query.procedure.ProcedureParameter; /** - * Describes the function return for ProcedureCalls that represent calls to - * a function ({@code "{? = call ...}} syntax) rather that a proc ({@code {call ...}} syntax) + * Describes the function return value of a {@link ProcedureCall} + * executed via a JDBC escape of form ({@code "{? = call ...}}. + * That is, the {@code ?} parameter occurring before the {@code =}. * * @author Steve Ebersole + * + * @since 6.0 */ +@Incubating public interface FunctionReturn extends ProcedureParameter { + /** + * The {@linkplain org.hibernate.type.SqlTypes JDBC type code} + * representing the SQL type of the function return value. + */ int getJdbcTypeCode(); } diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java b/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java index 7301cd92580a..bdab4e201754 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java @@ -14,41 +14,61 @@ import jakarta.persistence.StoredProcedureQuery; import jakarta.persistence.TemporalType; +import org.hibernate.Incubating; import org.hibernate.MappingException; +import org.hibernate.query.BindableType; import org.hibernate.query.SynchronizeableQuery; import org.hibernate.query.CommonQueryContract; import org.hibernate.query.procedure.ProcedureParameter; -import org.hibernate.type.BasicTypeReference; /** - * Defines support for executing database stored procedures and functions. + * Defines support for executing database stored procedures and functions using the + * {@linkplain java.sql.CallableStatement JDBC stored procedure SQL escape syntax}. *

- * Note that here we use the terms "procedure" and "function" as follows: