This is a good recipe for 3.0. In 3.1 you are allowed to merge multiple projects when creating a ServerRuntime, so you can merge multiple mappings to get the behavior that you need. However... Are you sure you want to switch DataNodes? DataNodes by themselves don't have many configuration properties. All the DB connection info is really about the underlying javax.sql.DataSource and that can be tweaked differently. Earlier you wrote:
> Yeah, I'm mainly interested in supporting the same schema on multiple > databases So this means 1 database in a given app, just a different database between the apps (or app executions)? In this case you can either use JNDI to map the DataSource, without changing anything in Cayenne (there is a nifty thing called AutoAdapter that automatically installs the right DbAdapter depending on the target DB type, so no need to know the adapter upfront). Or check this PDF (Chapter 11 and Appendix A) for properties that allow to specify the DB connection in runtime: http://people.apache.org/~aadamchik/misc/cayenne-guide-08302011.pdf AutoAdapter is at play here is well. Andrus On Sep 26, 2011, at 6:35 PM, Michael Gentry wrote: > Hi John, > > This is completely untested, but try something like: > > Configuration configuration = Configuration.getSharedConfiguration(); > DataDomain dataDomain = configuration.getDomain(); > DataMap dataMap = dataDomain.getMap("my map name"); > DataNode oldNode = dataDomain.getNode("old node name); > DataNode newNode = dataDomain.getNode("new node name); > > oldNode.removeDataMap(dataMap); > newNode.addDataMap(dataMap); > dataDomain.reindexNodes(); // maybe > > mrg > > > On Mon, Sep 26, 2011 at 10:49 AM, John Huss <[email protected]> wrote: >> At runtime how do I switch my model to use a different data node that was >> previously defined in the in model? I'm using trunk. >> >> Thanks, >> John >> >
