cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wernke zur Borg <wer...@zur-borg.de>
Subject Replacing DataSource in Cayenne 3.1 has no effect
Date Thu, 26 May 2011 10:00:48 GMT
Hi all,

I am referring to FAQ "Setting Database Connection" here: 
https://cwiki.apache.org/CAY/setting-database-connection.html

Firstly, in 3.1 the SharedConfiguration no longer exists, so we have to 
use the ServerRuntime instead:

     ServerRuntime runtime = ...;
     DataDomain domain = runtime.getDataDomain();
     DataNode node = domain.getNode("DB1");
     node.setDataSource(dataSource);

However, this setting does not have the desired effect. When the 
connection to the database is established, still the original definition 
from the config file is taken.

I have traced down this problem and found that the DataNode has a 
DbAdapter, which has its own DataSource object. This gets set in the 
ServerRuntime.getDataDomain() call above.

The only way I found around this is by explicitly creating a new adapter 
with my data source:

     node.setAdapter(new AutoAdapter(dataSource));

However, the AutoAdapter default constructor is deprecated, and I could 
not find an easy way to use the recommended method with a DbAdapterFactory.

Any ideas?

Thanks for any hint.

Wernke





Mime
View raw message