Re: Question about using a library having Cayenne embedded within a project using Cayenne

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Nov 11 2007 - 10:35:58 EST

  • Next message: Andrus Adamchik: "Re: MS SQLServer 1.2 JDBC driver and responseBuffering"

    Hi Sukanya,

    The simplest way to resolve such conflicts is to avoid place
    cayenne.xml in the root of the jar (place it in a package
    subdirectory instead). And then instantiate a separate Configuration
    for each cayenne.xml instead of using a shared one:

    http://cayenne.apache.org/doc/customizing-configuration.html

    DefaultConfiguration c1 = new DefaultConfiguration();
    c1.addClassPath("my/package/conf1");
    c1.initialize();

    DefaultConfiguration c2 = new DefaultConfiguration();
    c2.addClassPath("my/package/conf2");
    c2.initialize();

    Andrus

    On Nov 7, 2007, at 10:47 PM, Sukanya Ratanotoyanon wrote:

    > Hello,
    >
    > I'm having a problem getting a correct DataDomain when I'm using a
    > library
    > containing cayenne objects. Basically, I'm working on a project using
    > Cayenne. I need the database URL, usename and password to be
    > configurable.
    > Therefore, I have this method to set up them up like this:
    >
    > Configuration config =
    > Configuration.getSharedConfiguration();
    >
    > DataDomain domain = config.getDomain();
    > DataNode cNode = domain.getNode(LINK_DB_NODE);
    > ....
    > ....
    >
    > I received a library that also uses Cayenne to map the database,
    > and tried
    > to integrate this library into my project. However, after
    > integration, when
    > I call Configuration.getSharedConfiguration(), it loads the
    > configuration
    > from the cayenne.xml in the library instead of the one I'm using
    > for the
    > project. So when I tried to get my DataNode, it cannot be founded.
    > This
    > results in NullPointerException when I use my DataNode object. Is
    > there a
    > way to work around this, or do I miss something? I just start using
    > Cayenne
    > not very long ago and would appreciate any helps.
    >
    > Thank you very much,
    > Sukanya



    This archive was generated by hypermail 2.0.0 : Sun Nov 11 2007 - 10:36:32 EST