Skip to Main Content

Integration

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

Toplink JPA Calling Oracle Function Return sys_refcursor

SQL_UsersDec 22 2014 — edited Dec 22 2014

I have a function which return sys_refcursor and I am trying to call this using JPA(1.0)

@NamedNativeQuery( name = "getEmpsByDeptId"

        , query = "{ ? = call my_pck.getEmployees(:longName)}"

        , resultClass = Employee.class

        , hints = { @QueryHint(name = "org.hibernate.callable", value = "true")

                       , @QueryHint(name = "org.hibernate.readOnly", value = "true")

                       }

            )


DAOImpl


query = getEntityManager().createNamedQuery("getEmpsByDeptId");

query.setParameter("longName", "SCOTT");

list = (List<Employee>)query.getResultList();


However when I execute, I am getting the following exception


Exception [TOPLINK-6132] (Oracle TopLink Essentials - 2.1 (Build b52-fcs (09/24/2008))):

oracle.toplink.essentials.exceptions.QueryException Exception Description:

Query argument 2 not found in list of parameters provided during query execution.

Query: ReadAllQuery(test.entity.Employee) at oracle.toplink.essentials.exceptions.QueryException.namedArgumentNotFoundInQueryParameters

I have tried using

call my_pck.getEmployees(?)}"

and

query.setParameter(1, "SCOTT");

However error remains the same and how can I resolve this issue?

I have used the same function with Hibernate using JPA2.0 and it has worked.

Thank

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 19 2015
Added on Dec 22 2014
0 comments
1,263 views