Hi Cris,
The way Cayenne does DataObject comparison is a key to understanding
your problem. See more discussion of that here -
http://www.objectstyle.org/cayenne/lists/cayenne-user/2004/09/0100.html
You don't show how you obtain "filterObj" instance, but basically doing
"toDomainObject = $obj" with a known object parameter is the same in a
way as doing "queryResultList.contains(filterObj)". If filterObj comes
from a DataContext other than the one used to run the query, this will
always be false.
As for the HOLLOW vs. COMMITTED state, it could be that your
"filterObj" was HOLLOW *before* the query, and as a result of the query
it was "inflated" (again, because of uniquing, Cayenne populated an
existing registered hollow object with query values instead of creating
a new one). As you don't show how you obtain filterObj, this is just a
guess, but it seems a reasonable explanation to me.
Andrus
On Oct 7, 2004, at 4:19 PM, Cris Daniluk wrote:
> I am trying to use a named query with an in-memory expression as
> follows:
>
> DataContext context = DataContext.createDataContext();
> SelectQuery q = (SelectQuery)
> context.getEntityResolver().getQuery("NamedQuery");
>
> Map params = new HashMap();
> params.put("obj", filterObj);
>
>
> Expression qual = Expression.fromString("toDomainObject=$obj");
> return (RefJurisdictionInLang) qual.expWithParameters(params).
> filterObjects(context.performQuery(q)).get(0);
>
> Before someone asks why I'm not just using getToDomainObject(), I've
> simplified the expression for testing and to make the post more clear
> :)
>
> The problem is the expression is returning an empty list every time,
> despite
> there being a match. After going through the debugger, I've found that
> its
> "finding a match".. For some reason, Cayenne has made two different
> objects,
> one hollow and one committed. The object I'm using in my map is
> committed,
> but the objects the expression is comparing against are all hollow.
> This
> does not make sense as the query is set to prefetch the toDomainObject
> relationship.
>
> Is there a reason why Cayenne is comparing against hollow objects when
> doing
> the in-memory evaluation?
>
> Thanks,
>
> Cris
>
>
>
This archive was generated by hypermail 2.0.0 : Sat Oct 09 2004 - 12:05:47 EDT