Hi
Thanks for the info, Andrus.
To be quite honest, I didn't quite understand the V1.2 features, so I
might wait around for some better docs/examples on that.
However, I did manage to programmatically modify the DataNode used for a
particular Map.
I created both DataNodes in the same project.
For the record, this is the code that I used:
// targetDatabase is a parameter to this function
Configuration conf = Configuration.getSharedConfiguration();
DataDomain domain = conf.getDomain();
DataMap map = domain.getMap("TheDomainMap");
Collection dataNodes = domain.getDataNodes();
for (Iterator iter = dataNodes.iterator(); iter.hasNext();) {
DataNode dataNode = (DataNode) iter.next();
if (dataNode.getName().equalsIgnoreCase(targetDatabase)) {
System.out.println("Adding Node:" + dataNode.getName() +
" to Map:" + map.getName());
dataNode.addDataMap(map);
} else {
System.out.println("Removing Node:" + dataNode.getName()
+ " from Map:" + map.getName());
dataNode.removeDataMap(map.getName());
}
}
Many thanks,
Howard
-----Original Message-----
From: Andrus Adamchik [mailto:andru..bjectstyle.org]
Sent: Sunday, 18 December 2005 3:33 AM
To: cayenne-use..bjectstyle.org
Subject: Re: Programmatically switching between DataNodes
In Cayenne 1.1 your options are (1) programatic switch of DataNode or
(2) using cdeploy Ant task to re-assemble you app for deployment:
http://objectstyle.org/cayenne/userguide/deploy/cdeploy.html
Cayenne 1.2 supports auto-detection of the DB type (so you don't have to
switch adapter when going from MySQL to Oracle), and also reading JNDI
info from preferences:
http://objectstyle.org/confluence/display/CAY/1.2+User+Guide
So if you can use real JNDI in deployment, you won't have to change
anything at all.
Andrus
On Dec 17, 2005, at 8:19 AM, Howard Treisman wrote:
> Hi
>
> I'm running a project where I develop locally against MySQL, and
> deploy on my client's site against Oracle. I'd like to have a single
> Domain (I hope I'm using the correct terminology here), with two
> different DataNodes, one for development, and one for production.
>
> I presume there is some reasonably straight-forward way of telling
> Cayenne which of the two DataNodes to use. I've really had a very good
> look in both the Javadocs and User Guide, but can't find this
> information.
>
> Could anyone help me?
>
> Many thanks,
> Howard
>
>
>
This archive was generated by hypermail 2.0.0 : Mon Dec 19 2005 - 04:37:50 EST