I have a well normalized database and a query that needs to do several joins as well as a filter on one of the joined tables. My efforts to optimize the query on the database side (postgresql) have shown that I can get a dramatic (2 orders of magnitude) increase in speed if I change the order of my join statements.
The problem I have is that I'm using Hibernate Criteria to build the query and I don't know how to guarantee the order of the resulting joins when I use createAlias. For example:
Code:
criteria.createAlias("examTime","et");
criteria.createAlias("patient","pat");
criteria.createAlias("metadata","m");
criteria.createAlias("procedure","pro");
This creates an arbitrary (I honestly can't figure out what's deciding within hibernate) order to the joins.
How do I force the order of the joins in the emitted SQL? Using HQL is not an option for me.
Thanks,
-Max