Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] StoredProcedureCall, ReadAllQuery exception

It means if you want the procedure to return objects, you need to map the
class using a RelationalDescriptor, otherwise use a DataReadQuery and just
select data.

You would normally map the data using JPA, using either annotations or
orm.xml.  Or you can use the native EclipseLink project.xml or
RelationalDescriptor API.



Oggie wrote:
> 
> Hi,
> 
> I am trying several StoredProcedureCall methods.
> 
> This one works ok,
> 
> public static void getEmployees() {
>         StoredProcedureCall spcall = new StoredProcedureCall();
>         spcall.setProcedureName("EMPLOYEEPKG.GETALLEMPLOYEES");
>         spcall.useNamedCursorOutputAsResultSet("MYCSR");
> 
>         List<DatabaseRecord> employees = (Vector)
> getSession().executeSelectingCall(spcall);
> 
>         for(DatabaseRecord dr: employees) {
>             System.out.println("EMP_ID => " + dr.get("EMP_ID"));
>             System.out.println("F_NAME => " + dr.get("F_NAME"));
>             System.out.println("L_NAME => " + dr.get("L_NAME"));
>             System.out.println(); System.out.println();
>         }
> }
> 
> But the following throws an exception,
> 
> public static void getEmployee(BigDecimal employeeId) {
>         StoredProcedureCall spcall = new StoredProcedureCall();
>         spcall.setProcedureName("EMPLOYEEDETAILPKG.GETEMPLOYEEDETAIL");
>         spcall.addNamedArgument("EMP_ID", "employeeId");
>         spcall.useNamedCursorOutputAsResultSet("MYCSR");
> 
>         ReadAllQuery query = new ReadAllQuery();
>         query.setReferenceClass(Employee.class);
>         //query.setEJBQLString("SELECT OBJECT(emp) FROM Employee emp WHERE
> emp.empId = ?1");
>         query.setCall(spcall);
>         query.addArgument("EMP_ID");
> 
>         Vector args = new Vector();
>         args.add(employeeId);
> 
>         getSession().executeQuery(query, args);
>  }
> 
> Here is the exception,
> 
> [EL Info]: 2010-04-14
> 21:11:20.125--DatabaseSessionImpl(31789152)--Thread(Thread[main,5,main])--
> login successful
> Exception in thread "main" Local Exception Stack: 
> [EL Warning]: 2010-04-14
> 21:11:20.234--DatabaseSessionImpl(31789152)--Thread(Thread[main,5,main])--Exception
> [EclipseLink-6007] (Eclipse Persistence Services - 2.0.0.v20091127-r5931):
> org.eclipse.persistence.exceptions.QueryException
> Exception [EclipseLink-6007] (Eclipse Persistence Services -
> 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.QueryException
> Exception Description: Missing descriptor for [class model.Employee].
> Query: ReadAllQuery(referenceClass=Employee )
> Exception Description: Missing descriptor for [class model.Employee].
> Query: ReadAllQuery(referenceClass=Employee )
>         at
> org.eclipse.persistence.exceptions.QueryException.descriptorIsMissing(QueryException.java:433)
>         at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.checkDescriptor(ObjectLevelReadQuery.java:660)
>         at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.prePrepare(ObjectLevelReadQuery.java:1895)
>         at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrePrepare(ObjectLevelReadQuery.java:748)
>         at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.checkEarlyReturn(ObjectLevelReadQuery.java:681)
>         at
> org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:619)
>         at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
>         at
> org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2322)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1181)
>         at testapplication.Test.getEmployee(Test.java:90)
>         at testapplication.Test.main(Test.java:41)
> Java Result: 1
> 
> What does it mean?
> 
> Thanks in advanced,
> Jose
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/StoredProcedureCall%2C-ReadAllQuery-exception-tp28247225p28287879.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top