1. Query createNativeQuery(
String sql, Class entityClass)
Does this only work for query returning all values of entity class. For example (select * from employee, employee.class).
I tried this using select name, age from employee, employee.class. This did not work.
I tried the above by using @ResultSetMapping.
@SqlResultSetMapping(name="myquery", entities={@EntityResult(entityClass=Employee.class, fields={@FieldResult(name="name", column="name")})})
Query query = em.createNativeQuery("SELECT name FROM EMPLOYEE", "myquery");
List result = query.getResultList();
SCJP 1.4, SCWCD 1.4, SCBCD 1.5, TOGAF 9, Comptia Cloud+