Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Calling preparedStatement/Function the JPA way
Calling preparedStatement/Function the JPA way [message #755450] Tue, 08 November 2011 09:53 Go to previous message
Neikius Mising name is currently offline Neikius Mising name
Messages: 32
Registered: April 2011
Member
Well, the JPA documentation suggests this:
http://en.wikibooks.org/wiki/Java_Persistence/Advanced_Topics#Stored_Procedures


EntityManager em = getEntityManager();
Query query = em.createNativeQuery("BEGIN VALIDATE_EMP(P_EMP_ID=>?); END;");
query.setParameter(1, empId);
query.executeUpdate();


But this doesn't work for me.

Quote:
> Caused by: java.lang.IllegalStateException: You cannot call executeUpdate() on this query. It is the incorrect query type.


I guess EclipseLink has its own PreparedStatement/Function methods. But how do you invoke that using injected container-managed EntityManager? I know how to do stuff using EclipseLink Session construct, but inside this EJB context I just cannot get Session... clues, help? I am just stuck on this at every corner. Well, I can still get the connection direcly, but would like to avoid that if possible since I have managed to fetch data using JPA.

Is it worth trying at all?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Re: Mapping Compound PK with FK Reference?
Next Topic:Object: is not a known entity type.
Goto Forum:
  


Current Time: Thu May 23 23:01:06 EDT 2013

Powered by FUDForum. Page generated in 0.02493 seconds