Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0, 2.4.0
    • Fix Version/s: 2.4.1
    • Component/s: criteria
    • Labels:
      None

      Description

      It should be possible to set query hints in Java code, or in orm.xml, but it seems the orm:hint element is ignored.

      The following two options should result in the same query:

      1. Java only:
        em.createQuery("Select e from MyEntity e where e.type = 'literal'")
          .setHint(QueryHints.HINT_USE_LITERAL_IN_SQL, true)
          .getResultList()
        
      2. Named query
        • Define the query and the hint in orm.xml
          <named-query name="Query1">
              <query>Select e from MyEntity e where e.type = 'literal'</query>   
              <hint name="openjpa.hint.UseLiteralInSQL" value="true" />
          </named-query>
          
        • And then call the query without additional information
          em.createNamedQuery("Query1")
            .getResultList()
          

      However, (2) does not correctly take the query hint into account and thus literals are replaced with SQL positional parameters.

        Issue Links

          Activity

          Hide
          kariem Kariem Hussein added a comment -

          Provided patch and test case in PR2. I hope it can help you.

          Is there anything I can do to have this in a bugfix release for 2.3?

          Show
          kariem Kariem Hussein added a comment - Provided patch and test case in PR2 . I hope it can help you. Is there anything I can do to have this in a bugfix release for 2.3?
          Hide
          kariem Kariem Hussein added a comment -

          I attached the two commits from the pull request.

          Show
          kariem Kariem Hussein added a comment - I attached the two commits from the pull request.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 1692088 from Mark Struberg in branch 'openjpa/trunk'
          [ https://svn.apache.org/r1692088 ]

          OPENJPA-2601 fix 'hint' element in orm.xml parsing

          Txs to Kariem Hussein for the patch!

          Show
          jira-bot ASF subversion and git services added a comment - Commit 1692088 from Mark Struberg in branch 'openjpa/trunk' [ https://svn.apache.org/r1692088 ] OPENJPA-2601 fix 'hint' element in orm.xml parsing Txs to Kariem Hussein for the patch!
          Hide
          struberg Mark Struberg added a comment -

          txs for the patch, Kariem!

          Show
          struberg Mark Struberg added a comment - txs for the patch, Kariem!

            People

            • Assignee:
              struberg Mark Struberg
              Reporter:
              kariem Kariem Hussein
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development