cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Configuring listener for all db Classes
Date Wed, 03 Aug 2011 17:50:18 GMT
Hi Joe,

On Aug 3, 2011, at 10:29 AM, Joseph Senecal wrote:

> I'm trying to configure a single listener object to listen to a couple of events for
all objects. This is to update modCounts and lastModTimes just before the commit.
> The documentation says this is configured in the Cayenne modeler, but doesn't explain
how. I found how to specify a class and methods, but it doesn't seem to be getting called.

This is odd. This certainly works for me. Here is an example from one of my map.xml files
(created by the Modeler) :
This part is a listener within <obj-enntity> tags:

	<entity-listener class="">
		<post-persist method-name="objectPostPersistCallback"/>

This part is callbacks on persistent objects themselves:

	<post-add method-name="onPostAdd"/>
	<pre-update method-name="onPreUpdate"/>

These are per-entity callbacks/listeners. Are you setting a listener per DataMap? (I personally
haven't used "global" listeners, but those should work too). Could you confirm - we'll re-test
this case then.

> I can see how to do it programmatically, but is there a cleaner solution that I'm missing?

Personally I am moving to setting everything programmatically, as it allows me to have different
listeners for the same shared entities in different Java projects. So my preferred method
is the latest 3.1M2 API based on annotations:


But again - this is for per-entity listeners. Not per-DataMap. (Which reminds me - we need
to support this flavor in per-DataMap case).

View raw message