Hi Jesper,

You would definitely need multiple DataDomains, one per "cloned" database. However I think you can reuse EntityResolver object (and the DataMap that it stores). So you can do something like that to roll out a new database stack:

DataDomain mainDomain = ... // this one is loaded from cayenne.xml

DataDomain domainX = new DataDomain("domainX");
domainX.setEntityResolver(mainDomain.getEntityResolver());

// now manually set the DataNode for domainX and link it to the DataMap insider resolver

I've actually never tried this approach, but EntityResolver is (a) intended to be shared by multiple threads and (b) doesn't have a notion of an owning parent. So this should work.

HTH
Andrus



On Oct 1, 2008, at 2:55 AM, Jesper Grooss wrote:

Hi all

Hope this has not been answered before, or is trivial, but I could not find any info, and it has proven difficult for us to solve:

We have a set of databases that share the exact same structure. The databases are create dynamically, so we do not even know their names beforehand. We have created a datamap xml file once for a template database and are trying to reuse this template datamap for all the databases. Several of the databases are active at the same time.

I am aware of the example in:
 http://cwiki.apache.org/CAY/copying-datamaps.html
but that seems only to work when you are not using the different databases at the same time.

Our current solution is to update the schema name for each dbentity before every use of the datamap, but that is quite error prone and does not perform that very well (and not at all if/when we go multi- threaded...).

Is there a smart way to do this? One option is to make a deep clone of the template datamap, and update the schema name then, but do we have to do that manually or is there a smarter way?

Thanks
Jesper


Reply via email to