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

前端 未结 6 1329
孤城傲影
孤城傲影 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:12

    • PostgreSQL
    • Hibernate
    • Kotlin

    CREATE OR REPLACE FUNCTION your_procedure() RETURNS text AS $$
    BEGIN
        RETURN 'Some text';
    END;
    $$ LANGUAGE plpgsql;
    

    val query = session.createNativeQuery("SELECT your_procedure()")
    query.list().map {
        println("NativeQuery: $it")
    }
    

提交回复
热议问题