Cloning DataDomain

From: Mirko Teran Ravnikar (mirko.tera..mail.com)
Date: Mon Sep 07 2009 - 03:10:51 EDT

  • Next message: open.pumpkin: "Easily Import/Export tables"

    Hello.

    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 =
    Configuration.getSharedConfiguration().getDomain("ArrowDomain");
        LOGGER.debug("Source DataDomain: " + sourceDataDomain);

        DataDomain destDataDomain = new DataDomain(domainName,
    sourceDataDomain.getProperties());
        Configuration.getSharedConfiguration().addDomain(destDataDomain);
        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());
          destDataDomain.addMap(map);
        }

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

        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



    This archive was generated by hypermail 2.0.0 : Mon Sep 07 2009 - 03:11:49 EDT