Re: Cloning DataDomain

From: Michael Gentry (mgentr..asslight.net)
Date: Tue Sep 08 2009 - 10:12:49 EDT

  • Next message: Andrus Adamchik: "Re: Easily Import/Export tables"

    Hi Mirko, it looks to me like you are copying the DataNode, which
    means they'll all have the same DB connection.

    mrg

    On Mon, Sep 7, 2009 at 3:10 AM, Mirko Teran
    Ravnikar<mirko.tera..mail.com> wrote:
    > 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 : Tue Sep 08 2009 - 10:13:24 EDT