Hello,
I am trying to get below code snippet working. I am using JPA 2.0 with Spring 3.0.1. I have create MetaModel class Employee_. I get NullPointerException when control reach at Employee_.fName.
I tried defining Employee_ class in persistence.xml file same like how we define there entities.
Am I missing something?
Thanks,
Mahesh
Code:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery criteria = cb.createQuery(Employee.class);
Root<Employee> entity = criteria.from(Employee.class);
criteria.orderBy(cb.asc(entity.get(Employee_.fName)), cb.asc(entity.get(Employee_.lName)));
Query query = em.createQuery(criteria);