To control relationship refresh you can either use
DataContext.invalidateObjects(..) or plan a bit ahead and refresh it
together with the query that fetched the root object by using
prefetching on that relationship. E.g.
someQuery.addPrefetch("relatedRows");
List rows = context.performQuery(someQuery);
Judging from your example the prefetch option should be exactly what
you need.
Andrus
On Jun 9, 2008, at 11:08 PM, Chris Gamache wrote:
> Using Cayenne 2.0.3 ...
>
> I'm having problems when I use an accessor to get rows from a related
> table. It pulls fresh data the first time I use the accessor, but if
> data is modified outside of the Java application, it is not reflected
> the next time I use the accessor in a different execution stack within
> the same JVM.
>
> List rowsA = context.performQuery(someQuery);
> ...
> SomeTable dataSetA = rowA.getRelatedRows();
> //object rowA and dataSetA and someQuery pass out of scope
> ...
> //Data is Modified directly on the database, not in Java application
> ...
> List rowsB = context.performQuery(theSameQuery);
> ...
> SomeTable expectedModifiedButGotSetA = rowB.getRelatedRows();
>
>
> The primary key which the relation uses to get the related data
> doesn't change from rowsA to rowsB. We're looking at the same related
> rowset, just updated data.
>
> I would like to know what is the magic no-cache recipe to force that
> particular accessor to always pull fresh data from the database...
>
> It appears that SelectQuery doesn't suffer from the same problem.
>
> I'm sure there's some configuration switches that I can trip, but
> there are several places caching policies can be modified and several
> confusingly similar yet different options to choose from.
>
This archive was generated by hypermail 2.0.0 : Tue Jun 10 2008 - 03:06:29 EDT