Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Invalid binding with "IN" clause and entity
Invalid binding with "IN" clause and entity [message #1505779] Wed, 10 December 2014 09:55
Mauro Molinari is currently offline Mauro MolinariFriend
Messages: 285
Registered: July 2009
Senior Member
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?
Previous Topic:SEQUENCE table / row lock issue
Next Topic:Got NPE on Marshall with JAX-RS and multi requests
Goto Forum:
  


Current Time: Thu Apr 25 12:30:56 GMT 2024

Powered by FUDForum. Page generated in 0.03153 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top