`Type cannot be null` exception when trying to run out Stored Procedure using Spring Data JPA

后端 未结 4 1455
情书的邮戳
情书的邮戳 2021-01-28 18:07

I am trying to invoke a Stored Procedure whose signature looks like the following:

CREATE OR REPLACE PROCEDURE FIND_FIRST_BOOKMARK_GT(bookmark IN NUMBER, cur OUT         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-28 18:49

    Faced with the same issue using @Procedure. As a workaround, you could refer to the entityManager in the service class and call procedure from it.

    @Service
    public interface ResponseService {
    
        @PersistenceContext
        EntityManager entityManager;
    
        public Response findFirstBookmarkGreaterThan(Long bookmark){
              Query query  = entityManager.createNamedStoredProcedureQuery("Response.findFirstBookmarkGreaterThan");
              query.setParameter("bookmark", bookmark);
              return query.getFirstResult();
        };
    }
    

    Note that Response must be an @Entity.

提交回复
热议问题