cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mirko Teran Ravnikar <>
Subject Cloning DataDomain
Date Mon, 07 Sep 2009 07:10:51 GMT

I've been looking trough similar problems here but can't seem to find
a solution that would work so I'm posting a new question.

My situation is like this. I have an application that connects to
multiple databases that are selected at runtime. All of the databases
have same structure. In Cayenne modeller I have created a single
DataNode and DataMap with this structure. Now at runtime I would like
to clone that whole datadomain (in future it will probably have more
then 1 map/node).

I've used the code posted on website about copying datadomains and
modified to fit my needs. But I keep having same problem. After
creating 2 or more domains all of them use the same(last) database
connection. I'm guessing there is something I'm missing when cloning
datadomain, but I can't find out what it is.

Here is the code I'm using.

  public static void copyDataDomain(String domainName)
    LOGGER.debug("Copy data domain: " + domainName);

    // get source DataDomain
    DataDomain sourceDataDomain =
    LOGGER.debug("Source DataDomain: " + sourceDataDomain);

    DataDomain destDataDomain = new DataDomain(domainName,
    LOGGER.debug("Destination DataDomain: " + destDataDomain);

    // copy data maps
    LOGGER.debug("Copying data maps...");
    for(DataMap map : sourceDataDomain.getDataMaps())
      LOGGER.debug("Copying data map: " + map.getName());

    // copy data nodes
    LOGGER.debug("Copying data nodes...");
    for(DataNode node : sourceDataDomain.getDataNodes())
      LOGGER.debug("Copying data node: " + node.getName());

    LOGGER.debug("New data domain created: " + domainName);

I've also tried adding EntityResolver as it was suggested in one of
the thread, and a couple of other tips I found, but without any luck.

Kind regards,

--Mirko R. Teran
Sent from Ljubljana, Slovenia

View raw message