Including Oracle hints in JPA/Hibernate
Posted: Tue Feb 01, 2011 3:03 pm
Has anyone found a good way to include Oracle optimizer hints in HQL queries? I'd like to include the /*+ FIRST_ROWS */ hint in a query, but it looks like Hibernate doesn't support this.
The other options I see from my google searches are:
- rewrite the query to be a native sql query, or
- just before the query, do an
ALTER SESSION SET optimizer_mode = FIRST_ROWS;
and then do another ALTER SESSION after the query, setting the optimizer mode back to ALL_ROWS.
Just wondering if anyone has experience with this and could offer a recommendation.
The other options I see from my google searches are:
- rewrite the query to be a native sql query, or
- just before the query, do an
ALTER SESSION SET optimizer_mode = FIRST_ROWS;
and then do another ALTER SESSION after the query, setting the optimizer mode back to ALL_ROWS.
Just wondering if anyone has experience with this and could offer a recommendation.