Getting ref cursor from a SP is working when we use query.getResultList();
{code:java} StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("extractWebUser"); query.setParameter(1, userId); query.setParameter(2, period); query.setParameter(3, idClientLimit); query.execute(); *List resultList = query.getResultList();*
{code}
But when we try to get parameter by position or name, hibernate is throwing exception.
{code:java} Object outputParameterValue = query.getOutputParameterValue(4); {code}
org.hibernate.procedure.internal.AbstractParameterRegistrationImpl.java {code:java} ... ... public T extract(CallableStatement statement) { ... else if ( mode == ParameterMode.REF_CURSOR ) { throw new ParameterMisuseException( "REF_CURSOR parameters should be accessed via results" ); } ... {code}
From section 3.10.17.3 Stored Procedure Query Execution of the [JPA2.1 spec|http://download.oracle.com/otndocs/jcp/persistence-2_1-fr-eval-spec/index.html]:
{panel:title= My title JPA2.1 spec } When using REF_CURSOR parameters for result sets, the update counts should be exhausted before calling getResultList to retrieve the result set. Alternatively, the REF_CURSOR result set can be retrieved through getOutputParameterValue. Result set mappings will be applied to results corresponding to REF_CURSOR parameters in the order the REF_CURSOR parameters were registered with the query. {panel}
|
|