I have 3 tables
A(id, a1,a2)
B(id, fk_a_id, b1,b2)
C(id, fk_b_id, c1,c2)
related as
A (one to many) B (one to many ) C using Set and bidirectionally true
I have a use case like this:
Get me all A objects where B.b1 = "x" or C.c2 = "x"
I can implement this in two steps :
a ) if B.b1 defined,
then query on A , where B.b1 = "x" by joining A and B
b ) if B.b1 is not defined and C.c3 is defined
then query on B C.c2 = "x" by joining B and C , then
for each of these B's, get the A's
Are there any any other/elegant way of implementing this ?
Thanks
Shishir