I have a parent entity with an optional one-to-many relationship with a child entity.
FROM Parent i
LEFT OUTER JOIN i.children child
If I want to end up returning a p.id object even when elements in that p.children relationship are not present--i.e. because the LEFT OUTER JOIN didn't find any related objects--how would I check for this?
I had something like this (this is the relevant fragment from the WHERE clause):
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 WHERE clause fragment. Should I be doing something like:
AND (IS EMPTY(child) OR child.somethingOrAnother = 'someValue'...
...instead?
Thanks,
Best,
Laird
--
http://about.me/lairdnelson