// This stored procedure returns a cursor output parameter, and has one input parameter.
@NamedStoredProcedureQuery(
name = "ReadAddressById",
resultClasses = Address.class,
procedureName = "READ_ADDRESS",
parameters = {
@StoredProcedureParameter(mode=IN, name="P_ADDRESS_ID", type=Long.class),
@StoredProcedureParameter(mode=REF_CURSOR, name="CUR_ADDRESS", type=void.class)
}
)
@Entity
public class Address {
...
}
//Example calling a named stored procedure with a cursor output parameter
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("ReadAddressById");
query.setParameter("P_ADDRESS_ID", 12345);
query.execute();
List<Address> result = (List<Address>)query.getOutputParameterValue("CUR_ADDRESS");