I have managed to avoid using stored procedures, until now. I find plenty of questions about this but no useful answer.
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/querysql.html#sp_query raises more questions than it answers.
I have to call several Oracle stored procedures that have one OUT parameter and one or more IN parameters. i.e.
PROCEDURE IsAnythingAssignedToUser(
OUT_READ_PI_VARS OUT SYS_REFCURSOR,
IN_READER IN READ_PROCESS_INSTANCE.ASSIGNED_READER%TYPE,
IN_WORKFLOW_STATE_ARRAY IN String_Array
);
There's only one entity mapped to only one table. I try to call it in all the ways I can think of i.e.
Query query = entityManager.createNativeQuery("{? = call READ_WORKFLOW_PKG.IsAnythingAssignedToUser(?,?)}",ReadProcessInstance.class)
.setParameter(2, readerId).setParameter(3, workflowStateIds);
But I don't know what to do for the OUT parameter, is "{? = call" supposed to be parameter 1. I don't know if I MUST map sql-query or if I should use the annotations @SqlResultSetMapping, @NamedNativeQuery
If the Entity class is already has Table and Column annotations why do I need yet another mapping?