PostgreSQL 11 now supports stored procedures and I am trying to call one with Hibernate 5.3.7.Final and Postgresql 42.2.5 JDBC driver. Pre
As the pgJDBC 42.2.5 was released prior (Aug, 2018) to the PostgreSQL 11 release (Oct, 2018), I think this is currently a issue within the JDBC driver for PostgreSQL itself. I've created a issue within the GitHub repository.
For a workaround, you could rewrite the STORED PROCEDURE
as a FUNCTION
and use @NamedStoredProcedureQuery
or directly interact with the JDBC CallableStatement
e.g.:
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/", "postgres", "postgres");
CallableStatement callableStatement = conn.prepareCall("{call f_raise_wage_employee_older_than(?,?)}");
callableStatement.setInt(1, 20);
callableStatement.setInt(2, 500);
callableStatement.executeUpdate();
Or execute a native query with the EntityManager
:
this.em.createNativeQuery("CALL p_raise_wage_employee_older_than(1, 20)");
I'll update this answer as soon as I get an answer from the pgJDBC maintainer.
UPDATE:
This topic is already discussed in the Postgres Mailing list (https://www.postgresql.org/message-id/4285.1537201440%40sss.pgh.pa.us) and there is currently no solution. The only way is to pass native SQL queries to the database or rewrite the STORED PROCEDURE
as a FUNCTION