检查这个SO问题:
- 首先,您定义名为本地查询的存储过程:
@javax.persistence.NamedNativeQuery(name = "call_proc_ab", query = "{ call PROC_AB(:cmpid,:status,?) }", resultClass = Long.class, hints = { @javax.persistence.QueryHint(name = "org.hibernate.callable", value = "true") })- 然后使用以下命令执行它:
TypedQuery<Long> query = entityManager.createNamedQuery("call_proc_ab", Long.class); query.setParameter("cmpid",cmpid); query.setParameter("status",status); Long empId = query.getSingleResult(); 


