Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Call a plsql procedure with JPA in Spring
package mypackage;
import javax.persistence.EntityManager;
import javax.persistence.ParameterMode;
import javax.persistence.PersistenceContext;
import javax.persistence.StoredProcedureQuery;
import org.springframework.stereotype.Component;
@Component
public class ProcedureQueries {
@PersistenceContext
private EntityManager entityManager;
public String myfunc(final String param) {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("plsql_procedure_name")
.registerStoredProcedureParameter("pram", String.class, ParameterMode.IN)
.registerStoredProcedureParameter("result", String.class, ParameterMode.OUT)
.setParameter("pram", param);
query.execute();
return (String) query.getOutputParameterValue("result");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment