I am trying to figure out how to call a stored procedure using openJPA
How do I do that? I assume it is the same as calling a namedQuery, but I can't find anywhere online where to do this. I can't find one tutorial.
Also, how do you map it to an existing entity? Just have a ("nameOfStoredProc", NameOfEntity.class)
?
From the OpenJPA user manual.... Creating SQL Queries
In addition to SELECT statements, OpenJPA supports stored procedure invocations as SQL queries. OpenJPA will assume any SQL that does not begin with the SELECT keyword (ignoring case) is a stored procedure call, and invoke it as such at the JDBC level.
EntityManager em = ...;
Query query = em.createNativeQuery("StoredProcName", Magazine.class);
processMagazines(query.getResultList());