cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Working with DataContext after manipulating datasource
Date Thu, 12 Jan 2012 08:26:59 GMT
Yes, it is possible by implementing your own DataSource wrapper, so that it allocates the right
connection for a given execution thread, with the DB server switching done in your code outside
Cayenne. 

If you can describe the full scenario, I can comment on possible caveats related to switching
the DB underneath Cayenne.

Andrus

On Jan 11, 2012, at 9:02 PM, Daniel Bruegge wrote:

> Oh. Good to know. But is there a way to change the server dynamically
> when executing one statement?
> 
> On Wed, Jan 11, 2012 at 3:53 PM, Andrus Adamchik <andrus@objectstyle.org> wrote:
>> Hi Daniel,
>> 
>> Since DataSource is attached to the DataNode, which is one of the shared parts of
Cayenne stack, not only new DataContexts, but all the existing ones will pick it up the moment
you set it.
>> 
>> Andrus
>> 
>> On Jan 11, 2012, at 5:37 PM, Daniel Bruegge wrote:
>> 
>>> Hi,
>>> 
>>> I am trying to change dynamically the database server and connection
>>> in the application code. I am using the PoolManager and
>>> DataSource-setting like described in
>>> https://cwiki.apache.org/CAY/setting-database-connection.html.
>>> 
>>> What I was wondering:  if I change this connection things with the
>>> code above, will the next created DataContext using the new server?
>>> I am creating the context via
>>> 
>>> DataContext.createDataContext();
>>> 
>>> set to the new server?
>>> 
>>> Thanks & regards
>>> 
>>> Daniel
>>> 
>> 
> 


Mime
View raw message