Hi.
Say I have these entities:
Code:
A {
}
B {
private A a;
}
C {
private B b;
}
In other words, an A "has" many B's and a B "has" many C's.
Can I do this?
Code:
A {
@OneToMany(mappedBy = "b.a")
public Collection<C> getCs();
}
I was expecting to, but it seems I'm wrong. It would mean I wouldn't have to write a boring EJBQL queries or do iterations just to get the C's for an A.
If you can't, how do you usually handle those cases in your apps? If I write a method in A to retrieve the C's, it would mean I have to load and iterate the entire graph of B's first, which doesn't sound right. Retrieving them through queries in session beans is clumsy and plus you lost the OO approach advantages (like being able to write #{myA.cs} wherever I need those in the presentation pages).
TIA