How to get Hibernate entityManager.createNamedQuery results
hibernate, java, jpa, jpa-2.0
Solution
see i do like this
Query query = em.createQuery("SELECT e FROM Employee e WHERE e.name = :name ");
query.setParameter("name", name);
List<Employee> results = query.getResultList();
return results;
here i am returning list of Employee type , if you want to send one object then do like this
return results.get(0);
Regards
Anshul
Problem
I am using Hibernate 4.0 I have method in my DAO class like the following where method return Entity class `Employees`. I am calling an Oracle function which returns `sys_refcursor`. How can I return `entityManager.createNamedQuery` in my below method? Any help is highly appreciated. ``` @Override public Employees getEmployeeRecords(String employeeNumber) { <??> = entityManager.createNamedQuery("myfunction"); return <??>; } ```