The following is the syntax to get entity objects from a native sql query via addEntity() and using named SQL query.
String sql ="SELECT * FROM EMPLOYEE WHERE id = :employee_id";
SQLQuery query =session.createSQLQuery(sql); query.addEntity(Employee.class); query.setParameter("employee_id",10); List results =query.list(); |