Hello,
I have the following JPQL query:
SELECT i FROM MyEntity i WHERE i.anotherEntity = ?1 AND i NOT IN ?2
where I bind ?1 to an AnotherEntity instance and ?2 to a MyEntity instance.
Making EclipseLink print SQL I see this (please note I'm writing "*" here for simplicity):
SELECT * FROM `MyEntity` WHERE ((`anotherEntity_id` = ?) AND (`id` NOT IN (?)))
bind => [151, <MyEntity.toString() output>]
Instead, if I change the query to:
SELECT i FROM MyEntity i WHERE i.anotherEntity = ?1 AND i != ?2
I see, instead:
SELECT * FROM `MyEntity` WHERE ((`anotherEntity_id` = ?) AND NOT ((? = `id`)))
bind => [151, 6]
Symptom: the first query does not get the result I'm expecting. The result set should be empty, but in the first case I get a collection containing the MyEntity instance I specify as ?2. The second query works fine instead.
Looking at the "bind" output it seems like in the first case EclipseLink is not binding the correct values (I would expect to see "6" as the second parameter, while I see the toString() output of the MyEntity instance).
I'm executing this query through Spring Data, so the actual binding of parameters is Spring Data responsibility.
Am I doing something wrong? Is this a bug of EclipseLink?