http://www.objectstyle.org/confluence/display/CAY/Copying+DataMaps
(Might be helpful.) /dev/mrg -----Original Message----- From: Andrus Adamchik [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 07, 2006 2:03 AM To: [email protected] Subject: Re: Multiple Databases and Setting Connection The situation you describe is addressed by multiple DataDomains (data domain is the first thing you create in the Modeler when starting a project). One catch is that you can't share the DataMap between domains using the Modeler. So you may have to do some runtime configuration. E.g. you can have the following structure setup in the Modeler: DD1 DM1 DN1 DD2 DN2 Then you can do this on startup to share the DataMap (I think Michael also posted a similar example some time back) // find the DataMap Configuration c = Configuration.getSharedConfiguration(); DataDomain d1 = c.getDomain("DD1"); DataMap m1 = d1.getMap("DM1"); // link it to a second domain DataDomain d2 = c.getDomain("DD2"); DataNode n2 = d2.getNode("DN2"); n2.addDataMap(m1); d2.reindexNodes(); Another catch with multiple DataDomains is that you have to pass an appropriate domain name when creating a DataContext for a given user. So instead of DataContext dc = DataContext.createDataContext(); you'd have to do something like this: String domainName = ... // determine based on user group DataContext dc = DataContext.createDataContext(domainName); Andrus On Jun 7, 2006, at 4:22 AM, james wrote: > Gentry, Michael (Contractor <michael_gentry <at> fanniemae.com> > writes: > >> >> You need to have multiple DataNodes in your model -- one for each >> database. You also need multiple DataMaps. Each DataMap should >> contain >> the schema for one of the databases. Then in the modeler, under the >> DataMap Configuration section, select the DataNode to associate >> the map >> to. Cayenne will then use the right database connection for the >> objects >> you are working upon. >> > > Hi, > I have different groups of web users. A new database is created > for each > group. Hence I need one DataMap and multiple DataNodes. Can one > DataMap be > assigned to two or more DataNodes? > > Regards, > James > >
