If you use setMaxResults() method on a hibernate Criteria, hibernate creates a sub-query like
select * from ( select this_.TRANSACTION_ID as TRANSACTION_ID1_18_1_, this_.VERSION as VERSION2_18_1_, this_.TRANSACTION_TYPE as TRANSACTION_TYPE3_18_1_, ... from PMT_TRANSACTION where modification_date>... ) where rownum < 2000
and when you do addQueryHint(), it adds it on top instead of the sub-query:
select /*+ INDEX(this_ PMT_TRANSACTION_ID8) */ * from ( select this_.TRANSACTION_ID as TRANSACTION_ID1_18_1_, this_.VERSION as VERSION2_18_1_, this_.TRANSACTION_TYPE as TRANSACTION_TYPE3_18_1_, ... from PMT_TRANSACTION where modification_date>... ) where rownum < 2000
This way, the hint has no effect. It needs to be put into the sub-query. Looks like a bug to me. Any ideas if there is a work-around ?
|