I can't find any thread/issue on this looking in the forum or jira.
inequality operator used on a composite-id generate the corresponding sql using AND instead of OR (behaviour tested using hibernate 3.2.7 DB H2/Oracle)
mapping snippet:
Code:
<class name="d.p.entityIDMUnit.lim.bl.pom.impl.PPKone" table="PPKone">
<composite-id>
<key-property name="i" type="IntegerType">
<column name="c_i_5b145" precision="19" scale="0"/>
</key-property>
<key-property name="j" type="IntegerType">
<column name="c_j_4534d" precision="19" scale="0"/>
</key-property>
</composite-id>
...
sample HQL: from d.p.entityIDMUnit.lim.bl.pom.impl.PPKone p where (( ( p <> p ) or ( p.i = 1 ) ))
SQL:
Code:
select
ppkone0_.c_i_5b145 as c1_16_,
ppkone0_.c_j_4534d as c2_16_,
ppkone0_.version$ as version3_16_
from
PPKone ppkone0_
where
ppkone0_.c_i_5b145<>ppkone0_.c_i_5b145
and ppkone0_.c_j_4534d<>ppkone0_.c_j_4534d
or ppkone0_.c_i_5b145=1
as you can see parenthesis disappeared and the SQL production for the pk is checking the equality of the whole pk when the condition should be true if just one field of the two is different, that's it the correct production should be:
Code:
ppkone0_.c_i_5b145<>ppkone0_.c_i_5b145
OR ppkone0_.c_j_4534d<>ppkone0_.c_j_4534d
and the parenthesis become mandatory in order to avoid wrong results.
Explicit use of the id ( p.id <> p.id ) produce the same result.
I can't believe there's no other thread/issue on that so point me to the thread/issue if you know or tell me what is wrong in the code above :)
Thanks Paizo