I want to select all entities that are tied by a custom hierarchy:
@Entity
class Employee {
@Id
private long id;
@ManyToOne
private Company company;
}
@Entity
class Company {
@Id
private long id;
@ManyToOne
private LeisureGroup leisureGroup;
}
@Entity
class LeisureGroup {
@Id
private long id;
}
//select all companies that belong to a LeisureGroup
Select * from company where leisureGroupId = '123'
TODO: how can I select all employees that belong to the LeisureGroup (tied by the Company reference)? Do I have to use joins here? If yes, how?