I have am Employee entity and a Location entity. When retrieving a list of Employees, I would like to also retrieve each employee's current location. For various reasons, I do not want to persist the location as part of the Employee entity. Instead, I would like to lookup each Employee's location when retrieving a list of employees. I would like for each employee's locationName to be part of the Employee object returned by the Criteria query.
I thought to add a transient property to the Employee entity(see below) and set it when retrieving a list of Employee, but that results in an error org.hibernate.QueryException: could not resolve property: locationName of: com.csc.apps.contacts.model.Employee
Any ideas?
@Entity public class Employee { @Id private String employeeNumber; private int locationId; @Transient private String locationName; }
@Entity public class Location { @ID private int locationId; private String locationName; }
|