Hi all,
I'm having trouble ordering the joins in JPQL (with Hibernate 3). I have a database with about 20 tables and they're arranged in a sort of circle with two parts branching out, eg.
"-->" = "is joined to"
T1 --> T2 --> T3 --> T4 --> T5 --> T6 --> T7 --> T8 --> T1
and
T3 --> T3B --> T3C
and
T7 --> T7B --> T7C
I have to join all of these tables using "left join fetch". Joining T1, T2, ... T8, T1 is no problem...
Code:
select t1 from T1 t1
left join fetch t1.t2 t2
[...]
left join fetch t7.t8 t8
left join fetch t8.t1 t11
but then I get an error when attempting to join one of the 'branches'...
Code:
select t1 from T1 t1
left join fetch t1.t2 t2
[...]
left join fetch t7.t8 t8
left join fetch t8.t1 t11
left join fetch t3.t3b t3b
What is the correct ordering for joins?
Explanation :
The object/table t1 is actually the user and based on the user and based on their group/profile etc. we build menus and other stuff.
Why :
We're not allowed to use multiple requests to the database (we had 52 requests). Joining 'the circle' (T1, T2 ... T8, T1) with 'left join fetch' brings us down to 20 requests, but this is still too much. The application will be used by a huge amount of people all starting at 9 o'clock, so we don't want the log-in/create-menu phase to cripple the systems response time.
Any help much appreciated.