How to properly call PostgreSQL functions (stored procedures) within Spring/Hibernate/JPA?

前端 未结 6 1382
孤城傲影
孤城傲影 2021-01-12 04:11

I\'m using Spring MVC 4, Hibernate and PostgreSQL 9.3 and have defined function (stored procedure) inside Postgres like this:

CREATE OR REPLACE FUNCTION spa.         


        
6条回答
  •  无人及你
    2021-01-12 04:29

    If you want to keep it simple, just do this:

        em.createSQLQuery("SELECT * FROM spa.create_tenant(:t_name) ")
                              .setParameter("t_name", name)").list();
    

    Notice I used list() intentionally.. for some reason .update() didn't work for me.

提交回复
热议问题