Skip to content
Advertisement

How to call a PostgreSQL stored procedure with Hibernate

I want to create a Stored Procedure in PostgreSQL to make some calculation and return it to My java call. I have tried Most of the option from Java-Hibernate but not able to succeed. Below is my SP.

JavaScript

In Java How to call this procedure to get the values. NOTE: I’m not using hibernate XML files to call quires.

Please provide Java code(using Session) and any changes in procedure (if required).

Advertisement

Answer

You can use JPA StoredProcedureQuery for calling PostgreSQL stored procedures or functions

JavaScript

Or, if you want to use the Hibernate Session:

JavaScript

That’s it!

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement