[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Outer joined one-to-many question
|
Should be something like:
"SELECT e FROM Employee e LEFT OUTER JOIN e.projects projects WHERE
(e.projects IS EMPTY OR EXISTS(SELECT p FROM Project p WHERE (p
IN(e.projects) AND p.name LIKE 'A%')))"
On 8/19/2013 1:24 PM, Laird Nelson wrote:
I have a parent entity with an optional one-to-many relationship with a
child entity.
I am using LEFT OUTER JOIN in a query on the child entity.
The relevant excerpt from my query looks like this:
SELECT p.id <http://p.id>
FROM Parent i
LEFT OUTER JOIN i.children child
If I want to end up returning a p.id <http://p.id>object even when
elements in that p.children relationship are not present--i.e. because
the LEFT OUTER JOINdidn't find any related objects--how would I check
for this?
I had something like this (this is the relevant fragment from the
WHEREclause):
AND (child IS NULL OR child.somethingOrAnother = 'someValue'...
When I do this, I get the following exception/warning in the logs:
Exception [EclipseLink-6076] (Eclipse Persistence Services -
2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.QueryException
Exception Description: Object comparisons can only be used with
OneToOneMappings. Other mapping comparisons must be done through query
keys or direct attribute level comparisons.
Mapping: [org.eclipse.persistence.mappings.OneToManyMapping[children]]
To me, this looks like I can't really use "child" directly--as I am
doing in that WHEREclause fragment. Should I be doing something like:
AND (IS EMPTY(child) OR child.somethingOrAnother = 'someValue'...
...instead?
Thanks,
Best,
Laird
--
http://about.me/lairdnelson
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users