Closed
Description
Vishnudev K opened DATAJPA-1145 and commented
I was trying to execute a oracle procedure with spring-data-jpa and hibernate
PROCEDURE MY_PROC (
P_ID IN NUMBER,
P_PERIOD IN VARCHAR2,
P_LIMIT IN NUMBER,
P_CURSOR OUT T_CURSOR);
MyEntity.java
@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)
MyRepository.java
@Procedure(name = "myProc", procedureName = "MY_PROC")
List<ResultEntity> execMyProc(Long userId,String period,Long idClientLimit);
StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("extractWebUser");
query.setParameter(1, userId);
query.setParameter(2, period);
query.setParameter(3, idClientLimit);
query.execute();
List resultList = query.getResultList();
But on spring-data we need to use getOutputParameterValue Method instead of getResultList
Object outputParameterValue = query.getOutputParameterValue(4);
Then I discovered that the hibernate does not support REF_CURSOR
org.hibernate.procedure.internal.AbstractParameterRegistrationImpl.java
...
...
public T extract(CallableStatement statement) {
...
else if ( mode == ParameterMode.REF_CURSOR ) {
throw new ParameterMisuseException( "REF_CURSOR parameters should be accessed via results" );
}
...
As per the ticket
https://jira.spring.io/browse/DATAJPA-652
its working fine on eclipse link, but broken in hibernate for quite sometime.
(I have taken the data/details from the original ticket)
Reference URL: #207
Attachments:
- spring-data-jpa-bug-datajpa-652.zip (10.17 kB)