How to use Oracle hints in your query

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

You can use a ProjectionList as shown in this example:

ProjectionList proList = Projections.projectionList();

proList.add(Projections.sqlProjection("/*+INDEX_DESC(this_INDEX_NAME)*/ 1 as MYHINT",    new String[]{},    new Type[]{}));

//add properties from your class

proList.add(Projections.property("field1"));

proList.add(Projections.property("field2"));

proList.add(Projections.property("field3"));

c.setProjection(proList);

Hibernate Criteria - example code

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

The Hibernate Criteria API is a powerful library, which is well adapted for implementing multi-criteria search functionalities where queries must be built on the fly. For example it can be used to return data in a web search form resulting in cleaner, clearer, more reliable, and more maintainable code.

Here are some examples of the Criteria Api.

Read more: Hibernate Criteria - example code