Inclusion of Oracle Hint

Hi all,

Does anyone know of a good way using Hibernate to include an Oracle hint (after the select keyword) in the sql statement?

Thank you in advance

As explained in this article, you can use The addQueryHint method:

List<Long> postIds = entityManager
.createNativeQuery(
    "SELECT " +
    "     p.id " +
    "FROM " +
    "     post p " +
    "WHERE EXISTS ( " +
    "     SELECT 1 " +
    "     FROM " +
    "          post_comment pc " +
    "     WHERE " +
    "          pc.post_id = p.id AND " +
    "          pc.review = 'Bingo' " +
    ") " +
    "ORDER BY " +
    "     p.title ")
.setFirstResult(pageStart)
.setMaxResults(pageSize)
.addQueryHint("GATHER_PLAN_STATISTICS")
.addQueryHint("POST_WITH_BINGO_COMMENTS")
.getResultList();