Why my Query Hints are not executed in Hibernate?

Solution Unverified - Updated -

Issue

While trying to include query hints in hibernate configuration an error message is logged when query is run:

server.log.18:org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 11 [select m /*+index (PK_COLUMN) */ from QueryHint q where q.id.date1 >= :initialDate and q.id.date2 <= :endDate and q.id.text  >= '' and q.number = :no]

This is the Query Configuration used:

<named-query name="queryWithQueryHints">
  <query>
    <![CDATA[
       select m /*+index (PK_COLUMN) */
       from QueryHint q
       where
          q.id.date1 >= :initialDate   and
          q.id.date2 <= :endDate       and
          q.id.text  >= ''             and
          q.number = :no
    ]]>
  </query>
</named-query>

Environment

  • JBoss Enterprise Application Platform all versions
  • Hibernate all versions

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.