cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: How to create cayenne datamap on the fly
Date Sat, 07 Jul 2007 18:07:07 GMT
Hi there,

Actually Cayenne is one of the few ORM engines where you can define  
both your metadata, and persistent objects on the fly if you want to.  
So...

1. While I never tried loading DataMap XML from a remote URL, it  
should work. Just subclass  
'org.objectstyle.cayenne.conf.DefaultConfiguration', overriding  
'getMapConfiguration' method to open a remote URL. You may find this  
page useful when doing that:

http://cayenne.apache.org/doc20/customizing-configuration.html

2. Yes, you can totally do that using generic persistent classes:

http://cayenne.apache.org/doc20/generic-persistent-class.html

The main trick is to access the objects via DataObject interface  
methods instead of concrete setters and getters.

Andrus


On Jul 7, 2007, at 1:12 AM, mr.abanjo wrote:

> Hi all,
> i'm writing an application that try to be indipendent from the  
> business
> logic required.
> The main idea behind this project is to use reflection to create on  
> the fly
> the bean (CayenneDataObject) that normally i must write for map the  
> databese
> structure.
> What i need is:
> 1) load cayenne data map xml from a URL. Basically this URL point to a
> servlet that generate it on the fly. Normally this is the  
> configuration in
> cayenne.xml:
>
> <map name="datamap-foo" location="META-INF/cayenne-datamap- 
> foo.map.xml" />
>
> whant i need is something like this:
>
> <map name="datamap-foo" location="
> http://somedomain/cayenne-datamap-foo.map.xml" />
>
> is it possible?
>
> 2) i need to generate some DataObject on the fly. So i'm thinking  
> to use
> Reflection. Do you think that is possible?  The main idea is that  
> at runtime
> i don't know the structure of my entity. For example, "user" can be  
> composed
> only by "name" and "surname" attribute... or... have also  
> "address".. and so
> on. I don't want to create every time the corresponding DataObject.  
> I want
> to implements an engine that create them on demand.
>
> I don't know if this is a right approch on the problem. Maybe  
> cayenne has
> some API for doing this type of activity.
>
> Thanks in advance, for help.
>
> D.


Mime
View raw message