Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-6906

HHH-1780 Negation of EXISTS clause in HQL query does not work

    XMLWordPrintable

    Details

    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      A possible workaround is adding NOT clause in each expression, like this:

      FROM L0parameter l0parameter_ WHERE
      NOT (l0parameter_.zvst = '00')
      OR NOT EXISTS (SELECT 1 FROM L0parameter b)
      
      

      Which results in the following SQL Query:

      select
        l0paramete0_.ZNR as ZNR91_, l0paramete0_.ZVST as ZVST91_ 
      from
        L0PARAMETER l0paramete0_ 
      where
        l0paramete0_.ZVST<>'00' 
        or  not (exists (select 1 from L0PARAMETER l0paramete1_))
      

      Show
      A possible workaround is adding NOT clause in each expression, like this: FROM L0parameter l0parameter_ WHERE NOT (l0parameter_.zvst = '00') OR NOT EXISTS (SELECT 1 FROM L0parameter b) Which results in the following SQL Query: select l0paramete0_.ZNR as ZNR91_, l0paramete0_.ZVST as ZVST91_ from L0PARAMETER l0paramete0_ where l0paramete0_.ZVST<>'00' or not (exists (select 1 from L0PARAMETER l0paramete1_))
    • Release Notes Text:
      When the <literal>EXISTS</literal> statement was negated in Hibernate HQL, its was incorrectly translated to SQL as <code>not (exists</code>. This issue has been resolved and the statement is now correctly translated.
    • Release Notes Docs Status:
      Documented as Resolved Issue
    • Docs QE Status:
      NEW

      Description

      When using the following HQL Query in code:

      FROM L0parameter l0parameter_ WHERE
      NOT ((l0parameter_.zvst = '00')
      AND EXISTS (SELECT 1 FROM L0parameter b))
      

      Results in the following SQL Query:

      select
        l0paramete0_.ZNR as ZNR91_, l0paramete0_.ZVST as ZVST91_ 
      from
        L0PARAMETER l0paramete0_ 
      where
        l0paramete0_.ZVST<>'00' 
        or exists (
         select 1 from L0PARAMETER l0paramete1_
        )
      

      Note that the EXISTS clause is not correct because in our HQL Query I'm adding NOT in EXISTS clause too. However, the translation didn't recognize this negation.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                stliu Strong Liu
                Reporter:
                rimolive Ricardo Martinelli Oliveira
                Writer:
                Russell Dickenson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: