]
Isak Jonsson commented on HHH-6344:
-----------------------------------
(Supplied patch is for 4.1.0)
IN expression misses negation when using row-value queries
----------------------------------------------------------
Key: HHH-6344
URL:
https://hibernate.onjira.com/browse/HHH-6344
Project: Hibernate ORM
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: 0001-fix-for-HHH-6344-negated-row-value-IN-queries.patch,
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: