@Entity
public class Employee {
@Id @GeneratedValue public long ind;
@ManyToMany Set<Manager> managers = new HashSet<>();
@ManyToMany Set<Employee> friends = new HashSet<>();
}
@Entity
@NamedEntityGraph(
name="managerfriends",
includeAllAttributes=false,
attributeNodes = {
@NamedAttributeNode(value='friends')
}
)
public class Manager extends Employee { }