In my Entity class I have the following, calling a oracle function which returns sys_refcursor
@Entity
@javax.persistence.NamedNativeQuery(name = "getEmp",
query = "{ ? = call getemployees }", resultClass = Employees.class, hints = {
@javax.persistence.QueryHint(name = "org.hibernate.callable", value = "true") })
@Table(name = "EMPLOYEES")
public class Employees {
and in DAO I have
@Inject
private SessionFactory sessionFactory;
@Override
public List<Employees> getEmployees() {
List query = new ArrayList<Employees>();
try{
query = sessionFactory.getCurrentSession()
.getNamedQuery("getEmp").list();
}
catch(Exception e){
System.out.println("exception "+e.getMessage());
e.printStackTrace();
}
return query;
}
But when I run my application I am getting the following exception
exception Named query not known: getEmp SEVERE: org.hibernate.MappingException: Named query not known: getEmp at org.hibernate.internal.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:149) at org.hibernate.internal.SessionImpl.getNamedQuery(SessionImpl.java:1257) at net.test.employees.dao.EmployeesDAO.getEmployees(EmployeesDAO.java:34) at net.test.employees.service.EmployeesService.getEmployees(EmployeesService.java:24)
How can I resolve this issue? Any help is highly appreciable.