cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Setting Default Values for Entities
Date Sun, 23 Dec 2007 09:17:12 GMT

On Dec 23, 2007, at 6:05 AM, Aristedes Maniatis wrote:

>> Since the method for setting defaults in the db is the same accross  
>> the database depending only on field type I can put together  
>> something like the following to initialize objects following our  
>> rules...  still it does not work ROP :(   PersistentObject used for  
>> client seems to have no way to access the metadata like  
>> CayenneDataObject does, i.e. no getObjEntity()
> Yeah, anything you do with this will need to be server side, not in  
> the client. But lifecycle events work only on the server anyway, and  
> only once you've committed the object from the client. The code you  
> posted could go into the common superclass for your persistent  
> objects on the server. Catch the lifecycle event (either preUpdate  
> or prePersist) and fire off your code.

Yep, looks like defaults extraction can be done in a generic fashion,  
and be abstracted in a single listener (or persistent superclass). I  
prefer listener, as it wouldn't have to store shared state in static  
variables. BTW, this could be a nice addition to Cayenne core down the  
line (we can support runtime defaults extraction via DbAdapter).

On the ROP end for now invalidation with RefreshQuery maybe the only  
way to get the defaults from the server, but eventually we'd like to  
implement a smarter protocol that would pass any custom changes made  
via callbacks and listeners on the server back to the client.


View raw message