Skip to content

Provide support for ParameterMode.REF_CURSOR [DATAJPA-652] #1030

Closed
@spring-projects-issues

Description

@spring-projects-issues

Marcos Oliveira Junqueira opened DATAJPA-652 and commented

As described here spring-projects/spring-data-examples#44
I was trying to execute a procedure on spring-data-jpa with hibernate on oracle 11g database.

PROCEDURE MY_PROC (
    P_ID IN NUMBER,
    P_PERIOD IN VARCHAR2,
    P_LIMIT IN NUMBER,
    P_CURSOR OUT T_CURSOR);
@NamedStoredProcedureQuery(
        name = "myProc",
        procedureName = "MY_PROC",
        resultClasses = ResultEntity.class,
        parameters = {
            @StoredProcedureParameter(mode = ParameterMode.IN, type = Long.class),
            @StoredProcedureParameter(mode = ParameterMode.IN, type = String.class),
            @StoredProcedureParameter(mode = ParameterMode.IN, type = Long.class),
            @StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, type = void.class)
@Procedure(name = "myProc", procedureName = "MY_PROC")
    List<ResultEntity> execMyProc(Long userId,String period,Long idClientLimit);
I was able run the procedure programmatically
StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("extractWebUser");
query.setParameter(1, userId);
query.setParameter(2, period);
query.setParameter(3, idClientLimit);
query.execute();
List resultList = query.getResultList();

But spring-data uses getOutputParameterValue Method instead of getResultList

Object outputParameterValue = query.getOutputParameterValue(4);

And it makes a lot of problems with hibernate

Hibernate does not support REF_CURSOR: https://github.com/hibernate/hibernate-orm/blob/4.3.7.Final/hibernate-core/src/main/java/org/hibernate/procedure/internal/AbstractParameterRegistrationImpl.java

Finally, I moved to the EclipseLink and it worked perfectly


Affects: 1.6.4 (Dijkstra SR4)

Reference URL: spring-projects/spring-data-examples#44

Attachments:

Referenced from: pull request #130

0 votes, 6 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions