cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <>
Subject Re: Setting Default Values for Entities
Date Sun, 23 Dec 2007 04:05:23 GMT

On 23/12/2007, at 2:10 PM, Adam Yocum wrote:

> Hi Ari,
>  How can I execute an arbitrary query like the SHOW query to get the  
> map of property names and default values, I like that idea, I just  
> don't know how to get a plain query to execute with just a client  
> app.  The client has not db driver lib.  Can I use Cayenne to  
> execute an arbitrary query?

But if you can hardcode the choices of default values to just a few  
options (such as in the code you posted), then you will not need this.

>  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.

Ari Maniatis

Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

View raw message