James,
> Does this mean that every time I do a DataContext.performQuery(),
> Cayenne fetches the data from the database?
Yes, it will fetch from the db, but only for the entity you create a
SelectQuery for.
For example, I have two entities, Person and Address and I've set up the
relationship properly in my model (Person has a relationship called
"address", and Address has a reverse relationship called "person").
When I create a select query to fetch records from Person:
SelectQuery query = new SelectQuery(Person.class);
dataContext.performQuery(query);
This will hit the PERSON table every time it's executed. It will attempt to
pull all related Address objects from the data context. If related objects
aren't already fetched in the data context, cayenne well execute additional
queries to fetch Addresses.
If I later executed a SelectQuery on Address (with the same data context),
my Address object's relationship to "person" would come from the data
context and not refetched from the db.
Hope this helps.
eric
----- Original Message -----
From: "James Treleaven" <jametre..noreo.on.ca>
To: <cayenne-use..bjectstyle.org>
Sent: Monday, January 12, 2004 3:54 PM
Subject: Re: ObjectStore and Caching
> Andrus Adamchik wrote:
> > Stateful clustered applications would normally serialize session data
> > and then restore it on the node that handles current request. With Level
> > 1 cache, DataContext is serialized with all its cache, so it will be
> > propagated across the cluster, providing the same user experience as if
> > the app was running on a single server. So ideally there is no need to
> > change anything.
>
> Oh. I see. Very nice.
>
>
> Furthermore, I have re-read your posts and realized that I have probably
> been making some false assumptions about Cayenne's 'caching'.
>
> You said:
> > Refreshing objects or lists on every "getXYZProperty" method call
> > would be wasteful. It is up to the developer to refresh objects when
> > needed. E.g. by executing a select query at the right moment (all
> > returned objects will be refreshed) or by invalidating individual
> > object via DataContext.invalidateObject(...). So developer would have
> > to balance between probability of stale data and app performance.
>
>
> Does this mean that every time I do a DataContext.performQuery(),
> Cayenne fetches the data from the database? I was thinking that a
> second performQuery() on a given DataContext would grab data stored in
> "the cache" by the first performQuery() - but I just watched my
> Postgresql log while I did some performQueries ... and I see that this
> is not the case. The data is being fetched from Postgresql.
>
> My apologies. At least this discussion is archived for the next schmuck
> who comes along wondering how Cayenne caching works.
>
> James
This archive was generated by hypermail 2.0.0 : Mon Jan 12 2004 - 16:20:19 EST