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

    • Bug
    • Resolution: Done
    • Major
    • EAP_EWP 5.2.0
    • EAP_EWP 5.1.0
    • Hibernate
    • None
    • Workaround Exists
    • 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_))
    • 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.
    • Documented as Resolved Issue
    • 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.

      Attachments

        Activity

          People

            shaozliu Strong Liu(刘少壮) (Inactive)
            rhn-support-rmartine Ricardo Martinelli
            Russell Dickenson Russell Dickenson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: