I have a class AppUser
;
class AppUser {
private String firstName;
private String lastName;
//-- getters and setters
}
I a
Query:
Query q = session.createQuery(
"SELECT s from Student s WHERE s.appUser.firstName=:firstName AND s.appUser.lastName=:lastName");
q.setParameter("firstName", "John");
q.setParameter("lastName", "Doe");
For using Criteria, check this thread
Also take a look at this page from hibernate docs
You might need to add an alias...something like:
List students = session.createCriteria(Student.class).createAlias("appUser", "user").add(Restrictions.eq("user.firstName", firstName)).list();
Without an alias:
List students = session.createCriteria(Student.class).add(Restrictions.eq("appUser.firstName", firstName)).list();