Hibernate version: 3.1
Name and version of the database you are using: MySQL 4.1 (but valid on any MySQL and probably other DB too)
I love the Criteria API, it solves my current problems quite well. But I believe it could be made even more flexible.
I currently had performances problems in a range of SQL queries, and the way to solve it was to tell MySQL to use a particular index for this type of queries (the problem occurs in some multiple join with order by queries) via the
Code:
SELECT FROM table_name USE INDEX (index_name) ...
With Hibernate 3.1, I did not find a way to add this bit of SQL via the Criteria API, when I want to. I believe this could be possible if I patched hibernate for my purpose (modifying org.hibernate.sql.Select and AbstractEntityJoinWalker a bit), but I obviously would prefer a less hacky solution.
Writing SQL queries in the mapping file is not a good solution since I have lots of those queries with slightly different Expressions/Projections. (which is one of the reasons why I am using the Criteria API).
Is there already a way to do what I want that I did not see? If not, would this be seriously considered in a near future release?