Top Description Inners Fields Constructors Methods
org.hibernate.procedure.internal

public Class PostgreSQLCallableStatementSupport

extends AbstractStandardCallableStatementSupport
Class Inheritance
Imports
java.util.List, org.hibernate.HibernateException, org.hibernate.dialect.AbstractPostgreSQLStructJdbcType, org.hibernate.procedure.spi.FunctionReturnImplementor, .ProcedureCallImplementor, .ProcedureParameterImplementor, org.hibernate.query.OutputableType, org.hibernate.query.spi.ProcedureParameterMetadataImplementor, org.hibernate.sql.exec.internal.JdbcCallImpl, org.hibernate.sql.exec.spi.JdbcCallParameterRegistration, .JdbcOperationQueryCall, org.hibernate.type.SqlTypes, jakarta.persistence.ParameterMode

PostgreSQL implementation of CallableStatementSupport.

Until version 11, stored procedures weren't supported in PostgreSQL, but the JDBC driver allowed calling functions with the JDBC call syntax by translating to select statements. Unfortunately, the JDBC driver can't differentiate between functions and stored procedures and calling functions is not allowed with the PostgreSQL 11+ native 'call xxx' syntax. This is why the driver introduced a config property 'escapeSyntaxCallMode' that has the options 'callIfNoReturn', 'call' and 'select' (default).

For more details, see the driver documentation.

Since Hibernate knows if it is being asked to invoke a function or real procedure, the following implementation tries to be agnostic of the driver setting by using the native syntax where possible.

When a stored procedure is marked as function, it will use the CallMode#FUNCTION syntax, unless the return type is a REF_CURSOR, in which case it will use the CallMode#TABLE_FUNCTION syntax. For PostgreSQL 11+, it will always use the CallMode#NATIVE_CALL syntax when a procedure is not marked as function. If the first parameter is a REF_CURSOR it will use the CallMode#CALL_RETURN syntax for PostgreSQL before 11, but also if this is a function and the return type is a REF_CURSOR. In all other cases, it will use the JDBC escape CallMode#CALL syntax.

Even though the rendered callable is different, the behavior should match that of previous Hibernate versions, yet this should work regardless of the configured 'escapeSyntaxCallMode'.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
public static final PostgreSQLCallableStatementSupport
INSTANCE

Singleton access

private final boolean
public static final PostgreSQLCallableStatementSupport

Constructor Summary

AccessConstructor and Description
private
PostgreSQLCallableStatementSupport(boolean supportsProcedures)

Method Summary

Modifier and TypeMethod and Description
public JdbcOperationQueryCall
private static boolean
Inherited from org.hibernate.procedure.internal.AbstractStandardCallableStatementSupport:
registerParameters

Field Detail

INSTANCEback to summary
public static final PostgreSQLCallableStatementSupport INSTANCE

Singleton access

supportsProceduresback to summary
private final boolean supportsProcedures
V10_INSTANCEback to summary
public static final PostgreSQLCallableStatementSupport V10_INSTANCE

Constructor Detail

PostgreSQLCallableStatementSupportback to summary
private PostgreSQLCallableStatementSupport(boolean supportsProcedures)

Method Detail

interpretCallback to summary
public JdbcOperationQueryCall interpretCall(ProcedureCallImplementor<?> procedureCall)

Implements org.hibernate.procedure.spi.CallableStatementSupport.interpretCall.

Annotations
@Override
isFirstParameterModeRefCursorback to summary
private static boolean isFirstParameterModeRefCursor(ProcedureParameterMetadataImplementor parameterMetadata)
org.hibernate.procedure.internal back to summary

pack-priv final Enum PostgreSQLCallableStatementSupport.CallMode

extends Enum<PostgreSQLCallableStatementSupport.CallMode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final PostgreSQLCallableStatementSupport.CallMode
public static final PostgreSQLCallableStatementSupport.CallMode
private final String
public static final PostgreSQLCallableStatementSupport.CallMode
public static final PostgreSQLCallableStatementSupport.CallMode
private final String
public static final PostgreSQLCallableStatementSupport.CallMode

Constructor Summary

AccessConstructor and Description
private
CallMode(String start, String end)

Method Summary

Modifier and TypeMethod and Description
public static PostgreSQLCallableStatementSupport.CallMode
public static PostgreSQLCallableStatementSupport.CallMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CALLback to summary
public static final PostgreSQLCallableStatementSupport.CallMode CALL
CALL_RETURNback to summary
public static final PostgreSQLCallableStatementSupport.CallMode CALL_RETURN
endback to summary
private final String end
FUNCTIONback to summary
public static final PostgreSQLCallableStatementSupport.CallMode FUNCTION
NATIVE_CALLback to summary
public static final PostgreSQLCallableStatementSupport.CallMode NATIVE_CALL
startback to summary
private final String start
TABLE_FUNCTIONback to summary
public static final PostgreSQLCallableStatementSupport.CallMode TABLE_FUNCTION

Constructor Detail

CallModeback to summary
private CallMode(String start, String end)

Method Detail

valueOfback to summary
public static PostgreSQLCallableStatementSupport.CallMode valueOf(String name)
valuesback to summary
public static PostgreSQLCallableStatementSupport.CallMode[] values()