Class PostgreSQLCallableStatementSupport
- java.lang.Object
-
- org.hibernate.procedure.internal.AbstractStandardCallableStatementSupport
-
- org.hibernate.procedure.internal.PostgreSQLCallableStatementSupport
-
- All Implemented Interfaces:
CallableStatementSupport
public class PostgreSQLCallableStatementSupport extends AbstractStandardCallableStatementSupport
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
PostgreSQLCallableStatementSupport.CallMode.FUNCTION
syntax, unless the return type is a REF_CURSOR, in which case it will use thePostgreSQLCallableStatementSupport.CallMode.TABLE_FUNCTION
syntax. For PostgreSQL 11+, it will always use thePostgreSQLCallableStatementSupport.CallMode.NATIVE_CALL
syntax when a procedure is not marked as function. If the first parameter is a REF_CURSOR it will use thePostgreSQLCallableStatementSupport.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 escapePostgreSQLCallableStatementSupport.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'.
-
-
Field Summary
Fields Modifier and Type Field Description static PostgreSQLCallableStatementSupport
INSTANCE
Singleton accessstatic PostgreSQLCallableStatementSupport
V10_INSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JdbcOperationQueryCall
interpretCall(ProcedureCallImplementor<?> procedureCall)
-
Methods inherited from class org.hibernate.procedure.internal.AbstractStandardCallableStatementSupport
registerParameters
-
-
-
-
Field Detail
-
INSTANCE
public static final PostgreSQLCallableStatementSupport INSTANCE
Singleton access
-
V10_INSTANCE
public static final PostgreSQLCallableStatementSupport V10_INSTANCE
-
-
Method Detail
-
interpretCall
public JdbcOperationQueryCall interpretCall(ProcedureCallImplementor<?> procedureCall)
-
-