4

I am trying to add oracle optimizer to run query faster from application code using criteria api. There is addQueryHint() method in Criteria but it doesnt seem to work using the latest hibernate API.

After searching thru the web I found some hacks/workarounds but something is not working for me .. I create a select statement using the ArrayList of columns, I need to add /*+ PARALLEL(4) */ to the criteria using projections as. Any help is appreciated.

    ProjectionList projectionList = Projections.projectionList();

    while (viewIt.hasNext()) {
        viewName = viewIt.next();
        projectionList.add(Projections.property(viewName));
    }

    criteria.setProjection(projectionList);
Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135
Gary
  • 71
  • 4

1 Answers1

0

can you try to put in a Oracle hint by a adding a ProjectionList to the criteria.

ProjectionList proList = Projections.projectionList();
proList.add(Projections.sqlProjection("/*+INDEX_DESC(this_ MY_INDEX_NAME)*/ 1 as MYHINT",
    new String[]{},
    new Type[]{}));
//add properties from your class

Ref link : How to insert an "Optimizer hint" to Hibernate criteria api query

miken32
  • 42,008
  • 16
  • 111
  • 154
balamuruganv
  • 123
  • 6