[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3926) Restrictions.ne("field", value) creates incorrect SQL if value has a composite key

Thomas Dietmaier (JIRA) noreply at atlassian.com
Tue May 26 08:07:17 EDT 2009


Restrictions.ne("field", value) creates incorrect SQL if value has a composite key
----------------------------------------------------------------------------------

                 Key: HHH-3926
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3926
             Project: Hibernate Core
          Issue Type: Bug
          Components: query-criteria
    Affects Versions: 3.3.1
         Environment: Hibernate 3.3.1.GA, Hibernate Annotations 3.4.0, J2EE SDK 5_05, example is in HSQL, problem was originally found on oracle with hibernate 3.2.6.GA
            Reporter: Thomas Dietmaier
            Priority: Minor
         Attachments: CompositeNotEqual.zip

When applying Restrictions.ne for a value object where the entity has a composite ID

    Criteria ca = session.createCriteria(Container.class);
    ca.add(Restrictions.ne("thing", a));

Hibernate generates the following SQL:
Hibernate: select this_.id as id1_1_, this_.thing_item as thing2_1_1_, this_.thing_tenant as thing3_1_1_, thing2_.item as item0_0_, thing2_.tenant as tenant0_0_ from Container this_ left outer join Thing thing2_ on this_.thing_item=thing2_.item and this_.thing_tenant=thing2_.tenant where (this_.thing_item<>? and this_.thing_tenant<>?)

... which should probably be

   [...] where (this_.thing_item<>? OR this_.thing_tenant<>?)

sources attached

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list