cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Rothe <aro...@phosco.info>
Subject Creating or loading Datamap
Date Fri, 21 Jan 2011 09:26:03 GMT
Hello,

I try to write a short test program, which can use multiple data  
sources dynamically with Cayenne. At the moment I have finished the  
replacement for the driver.xml and cayenne.xml (I think):

--------------------------------

// init a connection
DataSourceInfo properties = new DataSourceInfo();
properties.setDataSourceUrl("jdbc:oracle:thin:@test:1521:play");
properties.setJdbcDriver("oracle.jdbc.OracleDriver");
properties.setMinConnections(1);
properties.setMaxConnections(1);
properties.setUserName("scott");
properties.setPassword("testme");

  PoolManager pmA = new PoolManager(
                     properties.getJdbcDriver(),
                     properties.getDataSourceUrl(),
                     properties.getMinConnections(),
                     properties.getMaxConnections(),
                     properties.getUserName(),
                     properties.getPassword());

DataMap map = new DataMap("test_db");
//??

DataNode node = new DataNode("dev_db");
node.addDataMap(map);
node.setDataSource(pmA);

DataDomain domainA = new DataDomain();
domainA.addNode(node);
domainA.addMap(map);

// get the context ??


// init another connection
properties.setDataSourceUrl("jdbc:oracle:thin:@test:1521:test");

PoolManager pmB = new PoolManager(
                     properties.getJdbcDriver(),
                     properties.getDataSourceUrl(),
                     properties.getMinConnections(),
                     properties.getMaxConnections(),
                     properties.getUserName(),
                     properties.getPassword());

map = new DataMap("test_db");
//??

node = new DataNode("test_db");
node.addDataMap(map);
node.setDataSource(pmB);

DataDomain domainB = new DataDomain();
domainB.addNode(node);
domainB.addMap(map);

// get the context ??


---------------------

The questions:

How I can load a predefined data map from a map.xml into my DataMap  
object without affecting the already defined objects (node, domain  
etc.)? Can I define the map dynamically? How I can create a  
DataContext for the domains I have?

I have a lot of different data sources, which are defined by some  
other parts of the application. The DataSourceInfo object must be  
changeable by the user and it can be, that I get changes on the  
database structure, so it must be possible to react on them with a new  
data-map at runtime.

Is it possible with Cayenne?

Tanks
André

Mime
View raw message