Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] EclipseLink + storedprocedure

The annotation supports stored procedures, not stored functions.  Please log
an enhancement request to have annotation support for stored functions.

In the mean time you can either create the EclipseLink StoredFunctionCall
using the org.eclipse.persistence.queries API.  You can add a DataReadQuery
or ValueReadQuery with this call as a named query to your EclipseLink
Session using a SessionCustomizer.  You could also execute the query through
the EclipseLink JpaQuery setDatabaseQuery(DatabaseQuery) API.

You could also convert your stored function to a stored procedure using an
output parameter, or wrap the stored function with a stored procedure.


Leon Derks-2 wrote:
> 
> Hello
> In my case I need to call a stored function.
> 
> I tried this:
> @NamedStoredProcedureQuery(name="persistImageInfoIntoLibrary", 
> procedureName="IMAGE_API.CREATE_IMAGE",       
>         
> procedureParameters={@StoredProcedureParameter(queryParameter="p_image_id"),
>                                  
> @StoredProcedureParameter(queryParameter="p_image_type_id"),
>                                  
> @StoredProcedureParameter(queryParameter="p_collection_id")}
> )
> 
> DAO:
> Query query = 
> getEntityManager().createNamedQuery("persistImageInfoIntoLibrary");
>         query.setParameter("p_image_id", 5);
>         query.setParameter("p_image_type_id", 200);
>         query.setParameter("p_collection_id", 99);
>        
>         Object object = query.getSingleResult();
> 
> But I get the exception:
> Local Exception Stack:
> Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0 (Build 
> SNAPSHOT - 20080409)):
> org.eclipse.persistence.exceptions.DatabaseException
> Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7:
> PLS-00221: 'CREATE_IMAGE' is not a procedure or is undefined
> ORA-06550: line 1, column 7:
> PL/SQL: Statement ignored
> 
> The IMAGE_API.CREATE_IMAGE is a stored function, that returns an id.
> 
> What am I doing wrong?
> 
> Leon
> 
> 
> Leon Derks wrote:
>> Hello
>>
>> If I am correct there are two ways to call a stored procedure :
>>
>> using entityManager.createNativeQuery();
>> Or
>> with the @NamedStoredProcedureQuery annotation.
>>
>> Can someone provide me an example of how to call an oracle stored 
>> procedure using the entityManager.createNativeQuery() method?
>>
>> Leon
> 


-----
---
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://www.nabble.com/EclipseLink-%2B-storedprocedure-tp17622213p17624421.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top