Hi Chris,

On Jul 8, 2008, at 3:59 PM, Chris Gamache wrote:
I can now say, beyond a shadow of a doubt, that cayenne is caching
relational requests when the same keys are used to retrieve the parent data
object.

Yeah, each object within a DataContext is guaranteed to exist as a single instance, so all its relationships will be preserved, even if it is fetched multiple times, unless you use prefetching.

The rows returned from the toMany request are volatile, and need to
be re-queried when a new SelectQuery is run.


You need to use prefetching.


someQuery.addPrefetch("thisRelationIsaToManyList");
context.execute(someQuery); //throws ClassCastException in the part of
the code where it is trying to prefetch.

How do I make certain the cayenne is not caching data from a relation
that returns a ToManyList? Probably not addPrefetch() because it
throws a ClassCastException.

Prefetching works. I guess you used the wrong prefetch key that caused the error, but that's no reason to give up. The string you pass to "addPrefetch" must be a relationship name for the entity that is a root of the query.

Andrus

Reply via email to