Ok, now I finally see what you are saying (sorry for being so slow :-)) Yes, a listener will only be notified of entity events and running a SQLTemplate won't cause such an event.

So how do we solve it? I would like to avoid tying a "query execution event" directly to cache refresh. Maybe instead we can attach this new type of events (at the beginning EJBQL/SQLTemplate events) to the same set of listeners as entity events? A listener can be defined to do a cache refresh of a certain group, or do something else entirely. Even the events can be defined in terms of specific entities. E.g. "query X generates 'post-update' event for entity Y" ... or not :-) Something to think about...

Idea was to create such architecture where "Persistent" (DBMS related)
layer is separate from Java logic and caching could be handled by only
map.xml changes.


The note below is a bit of an aside from the main topic. Just a general observation.... Interestingly, I have a somewhat opposite problem in my apps - I have lots of ad-hoc queries created dynamically in the code, and a number of different object modification flows working over the same set of entities. So I need different listeners for the same entity events across different apps, and as a result I am finding that mapping "events" in XML is too inflexible, and I am more in favor of in-code configuration of those. I guess at the end we'll allow both styles, and allow extra XML files to be merged in the shared mapping to address that.

Andrus


On Jul 20, 2010, at 5:51 PM, Evgeny Ryabitskiy wrote:
Thx, for your reply.

Now, I see only events related with Entity manipulations. Is there a
way to add listener for NamedQuery execution?

As I understand Event listeners could be configured in some "static"
section while Cayenne configuration initialization...
It's not so bad until you have ~30 cashed tables and almost 100-200
queries to that tables.
Problem that it's had to monitor that all Update queries got their
listener when this information is decomposed between Java Code and XML
with SQL Templates.

Idea was to create such architecture where "Persistent" (DBMS related)
layer is separate from Java logic and caching could be handled by only
map.xml changes.

Evgeny.

Reply via email to