You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by yongbl <i_...@yahoo.com.sg> on 2006/06/06 19:25:07 UTC
Multiple Databases and Setting Connection
Hi,
I am looking forward to adopt Cayenne, but I need some questions answered.
1) In my servlet, I wanted to update to multiple databases in a single thread. Is this possible with Cayenne?
2) I am managing my own pool manager in the web application. For every request, can I dynamically set the connection to be used by Cayenne?
Regards,
James
Send instant messages to your online friends http://asia.messenger.yahoo.com
Re: Multiple Databases and Setting Connection
Posted by james <i_...@yahoo.com.sg>.
Hi Andrus,
You have got my questions answered.
Many thanks for the explanation.
Have a nice day!
Regards,
James
RE: Multiple Databases and Setting Connection
Posted by "Gentry, Michael (Contractor)" <mi...@fanniemae.com>.
http://www.objectstyle.org/confluence/display/CAY/Copying+DataMaps
(Might be helpful.)
/dev/mrg
-----Original Message-----
From: Andrus Adamchik [mailto:andrus@objectstyle.org]
Sent: Wednesday, June 07, 2006 2:03 AM
To: cayenne-user@incubator.apache.org
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
>
>
Re: Multiple Databases and Setting Connection
Posted by Andrus Adamchik <an...@objectstyle.org>.
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
>
>
Re: Re: Multiple Databases and Setting Connection
Posted by james <i_...@yahoo.com.sg>.
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
Re: Multiple Databases and Setting Connection
Posted by james <i_...@yahoo.com.sg>.
Gentry, Michael (Contractor <michael_gentry <at> fanniemae.com> writes:
>
> 1) Yes.
> 2) I'm not certain. Is their any reason you can't use the current pool
> manager?
>
> /dev/mrg
>
Hi Michael,
1) Any reference where I can read up?
2) I am usng c3p0 without jndi, so that there isn't a need to configure tomcat.
Can I use Cayenne with c3p0, without jndi?
Regards,
James
Re: Multiple Databases and Setting Connection
Posted by Andrus Adamchik <an...@objectstyle.org>.
I'd say the answer is yes to the question #2 as well, as long as the
custom pool manager is a javax.sql.DataSource implementation or can
be wrapped in one.
Andrus
On Jun 6, 2006, at 9:30 PM, Gentry, Michael ((Contractor)) wrote:
> 1) Yes.
> 2) I'm not certain. Is their any reason you can't use the current
> pool
> manager?
>
> /dev/mrg
>
>
> -----Original Message-----
> From: yongbl [mailto:i_yongbl@yahoo.com.sg]
> Sent: Tuesday, June 06, 2006 1:25 PM
> To: cayenne-user@incubator.apache.org
> Subject: Multiple Databases and Setting Connection
>
>
> Hi,
>
> I am looking forward to adopt Cayenne, but I need some questions
> answered.
>
> 1) In my servlet, I wanted to update to multiple databases in a
> single
> thread. Is this possible with Cayenne?
>
> 2) I am managing my own pool manager in the web application. For
> every
> request, can I dynamically set the connection to be used by Cayenne?
>
> Regards,
> James
>
> Send instant messages to your online friends
> http://asia.messenger.yahoo.com
>
RE: Multiple Databases and Setting Connection
Posted by "Gentry, Michael (Contractor)" <mi...@fanniemae.com>.
1) Yes.
2) I'm not certain. Is their any reason you can't use the current pool
manager?
/dev/mrg
-----Original Message-----
From: yongbl [mailto:i_yongbl@yahoo.com.sg]
Sent: Tuesday, June 06, 2006 1:25 PM
To: cayenne-user@incubator.apache.org
Subject: Multiple Databases and Setting Connection
Hi,
I am looking forward to adopt Cayenne, but I need some questions
answered.
1) In my servlet, I wanted to update to multiple databases in a single
thread. Is this possible with Cayenne?
2) I am managing my own pool manager in the web application. For every
request, can I dynamically set the connection to be used by Cayenne?
Regards,
James
Send instant messages to your online friends
http://asia.messenger.yahoo.com