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'.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| public static final PostgreSQLCallableStatementSupport | INSTANCE
Singleton access |
| private final boolean | |
| public static final PostgreSQLCallableStatementSupport |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public JdbcOperationQueryCall | interpretCall(ProcedureCallImplementor<?> procedureCall)
Implements org. |
| private static boolean |
| INSTANCE | back to summary |
|---|---|
| public static final PostgreSQLCallableStatementSupport INSTANCE Singleton access | |
| supportsProcedures | back to summary |
|---|---|
| private final boolean supportsProcedures | |
| V10_INSTANCE | back to summary |
|---|---|
| public static final PostgreSQLCallableStatementSupport V10_INSTANCE | |
| PostgreSQLCallableStatementSupport | back to summary |
|---|---|
| private PostgreSQLCallableStatementSupport(boolean supportsProcedures) | |
| interpretCall | back to summary |
|---|---|
| public JdbcOperationQueryCall interpretCall(ProcedureCallImplementor<?> procedureCall) Implements org.
| |
| isFirstParameterModeRefCursor | back to summary |
|---|---|
| private static boolean isFirstParameterModeRefCursor(ProcedureParameterMetadataImplementor parameterMetadata) | |
| Modifier and Type | Field and Description |
|---|---|
| public static final PostgreSQLCallableStatementSupport. | |
| public static final PostgreSQLCallableStatementSupport. | |
| private final String | |
| public static final PostgreSQLCallableStatementSupport. | |
| public static final PostgreSQLCallableStatementSupport. | |
| private final String | |
| public static final PostgreSQLCallableStatementSupport. |
| Modifier and Type | Method and Description |
|---|---|
| public static PostgreSQLCallableStatementSupport. | |
| public static PostgreSQLCallableStatementSupport. |
| CALL | back to summary |
|---|---|
| public static final PostgreSQLCallableStatementSupport. | |
| CALL_RETURN | back to summary |
|---|---|
| public static final PostgreSQLCallableStatementSupport. | |
| end | back to summary |
|---|---|
| private final String end | |
| FUNCTION | back to summary |
|---|---|
| public static final PostgreSQLCallableStatementSupport. | |
| NATIVE_CALL | back to summary |
|---|---|
| public static final PostgreSQLCallableStatementSupport. | |
| start | back to summary |
|---|---|
| private final String start | |
| TABLE_FUNCTION | back to summary |
|---|---|
| public static final PostgreSQLCallableStatementSupport. | |
| CallMode | back to summary |
|---|---|
| private CallMode(String start, String end) | |
| valueOf | back to summary |
|---|---|
| public static PostgreSQLCallableStatementSupport. | |
| values | back to summary |
|---|---|
| public static PostgreSQLCallableStatementSupport. | |