[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6344) IN expression misses negation when using row-value queries

Gail Badner (JIRA) noreply at atlassian.com
Wed Aug 17 20:04:03 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43269#comment-43269 ] 

Gail Badner commented on HHH-6344:
----------------------------------

I've verified this is still a problem in 3.6.7.

> IN expression misses negation when using row-value queries
> ----------------------------------------------------------
>
>                 Key: HHH-6344
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6344
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.6.5
>         Environment: Using the PostgreSQL Dialect
> Tested on 3.6.5 and 3.6.0 with the same result. Works on 3.2, but there actual row value native queries are used
>            Reporter: Isak Jonsson
>         Attachments: MyEntity.java, MyRowValue.java
>
>
> The queries in the attached JPA entities behave differently regarding whether or not it is a row-value query.
> Test code using the attached entities:
> {noformat}
>         List<Integer> values1 = new LinkedList<Integer>();
>         List<MyRowValue> values2 = new LinkedList<MyRowValue>();
>         values1.add(1);
>         values1.add(2);
>         values2.add(new MyRowValue(3,4));
>         values2.add(new MyRowValue(5,6));
>         em.createNamedQuery("MyEntity.query1").setParameter("values", values1).getResultList();
>         em.createNamedQuery("MyEntity.query2").setParameter("values", values1).getResultList();
>         em.createNamedQuery("MyEntity.query3").setParameter("values", values2).getResultList();
>         em.createNamedQuery("MyEntity.query4").setParameter("values", values2).getResultList();
> {noformat}
> Results in the following SQL:
> {noformat}
> select myentity0_.id as id85_, myentity0_.a as a85_, myentity0_.b as b85_ from MyEntity myentity0_ where myentity0_.a in (? , ?)
> select myentity0_.id as id85_, myentity0_.a as a85_, myentity0_.b as b85_ from MyEntity myentity0_ where myentity0_.a not in  (? , ?)
> select myentity0_.id as id85_, myentity0_.a as a85_, myentity0_.b as b85_ from MyEntity myentity0_ where myentity0_.a=? and myentity0_.b=? or myentity0_.a=? and myentity0_.b=?
> select myentity0_.id as id85_, myentity0_.a as a85_, myentity0_.b as b85_ from MyEntity myentity0_ where myentity0_.a=? and myentity0_.b=? or myentity0_.a=? and myentity0_.b=?
> {noformat}
> (No "NOT" in the last line) 
> persistence.xml properties:
> {noformat}
>       <property name="hibernate.hbm2ddl.auto" value="update"/>
>       <property name="hibernate.show_sql" value="false"/>
>       <property name="dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
>       <property name="hibernate.use_sql_comments" value="true"/>
> {noformat}
> Thanks for any insight to this!

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list