Spring Data JPA NamedStoredProcedureQuery Multiple Out Parameters

前端 未结 4 1584
青春惊慌失措
青春惊慌失措 2021-02-01 04:04

I have a simple stored procedure I\'m using to test out Spring Data JPA Stored Procedure feature.

create or replace procedure plus1inout (arg in int,res1 out int         


        
4条回答
  •  不知归路
    2021-02-01 04:39

    It looks like @Procedure expects only one OUT parameter which is binded directly to the method return type...

    To handle multiple OUT params you can use the JPA API directly:

    StoredProcedureQuery proc = em.createNamedStoredProcedureQuery("plus1");
    
    proc.setParameter("arg", 1);
    proc.execute();
    Integer res1 = (Integer) proc.getOutputParameterValue("res1");
    Integer res2 = (Integer) proc.getOutputParameterValue("res2");
    ...
    

提交回复
热议问题