java - Hibernate JPA stored procedure call? -
java - Hibernate JPA stored procedure call? -
i using hibernate jpa. have below oracle stored procedure.
createorreplaceprocedure proc_ab ( in_name varchar2, in_lastname varchar2, out_emp_id outinteger )
how can invoke stored procedure?
check this question:
first define stored procedure named native query:
@javax.persistence.namednativequery(name = "call_proc_ab", query = "{ phone call proc_ab(:cmpid,:status,?) }", resultclass = long.class, hints = { @javax.persistence.queryhint(name = "org.hibernate.callable", value = "true") })
then execute using:
typedquery<long> query = entitymanager.createnamedquery("call_proc_ab", long.class); query.setparameter("cmpid",cmpid); query.setparameter("status",status); long empid = query.getsingleresult();
java database hibernate jpa stored-procedures
Comments
Post a Comment