I have a user table with different types of users. The type of the user is determined by user_type column in user table. I have a company table which has one to many relationship with User. I have different classes for different users like Guest, Admin (children of User class) each with a discriminator value.
My Company class has:
private Set<Guest> guests;
private Set<Admin> admins;
How can I write a single hql query to join company and user table to populate guest users into guest set and admin users into admin set?
Like select company left outer join fetch company.guests left outer join admin.guests. I cannot find a way to include user_type while making these joins.