RE: Oh, yeah...

From: Gentry, Michael (michael_gentr..anniemae.com)
Date: Mon Aug 02 2004 - 11:04:28 EDT

  • Next message: Laurence Gellert: "postgres PK serial column insert error"

    Funny you should ask that ... I had asked Andrus about that the other
    day. It's a little tricky, but here is the basic idea (note: I haven't
    had time to test this yet, so please let us know if it works):

    1. Create a "shared" DataDomain and DataMap in Cayenne Modeler. This
    will contain your schema definition. You won't need a DataNode here.

    2. Create a DataDomain for each DB you need to access (production and
    test, in your case). You will use these DataDomains later on to suck in
    the shared DataMap you created (step 1).

    3. Underneath each DB-specific DataDomain (step 2), create a DataNode
    with the JDBC connection for each environment's DB. You won't need a
    DataMap here.

    4. At run-time, you'll need to copy the shared DataMap into your
    DB-specific DataDomain. Check out
    Configuration.getSharedConfiguration.getDomain(dataDomainName). Use it
    to get your skeleton DB-specific DataDomain and the shared DataDomain.
    Then use
    skeletonDataDomain.addMap(sharedDataDomain.getMap("MySharedDataMap"))
    which should copy the shared schema into the skeleton one.

    That's as far as I've gotten so far. Other things interrupted my
    testing this out. I did have a few funky problems with the modeler, but
    you can work through them. You might also have to remove the shared
    DataMap (see removeMap("MySharedDataMap")) -- not certain, but you'd
    have two maps with entities with the same name otherwise. I hope not,
    because I was looking into making a utility application that could
    access our development/testing/acceptance/production DBs, all at the
    same time within the same web application. Basically, the schema is
    identical, but the connection dictionary differs.

    Please let us know how it works for you. If you don't need multiple
    connections, it might be much easier to just change the connection
    dictionary at deployment time.

    Thanks,

    /dev/mrg

    -----Original Message-----
    From: Todd O'Bryan [mailto:toddobrya..ac.com]
    Sent: Monday, August 02, 2004 8:59 AM
    To: cayenne-use..bjectstyle.org
    Subject: Oh, yeah...

    The other part of that question is, is there a way to have the same
    Cayenne configuration file be set up to connect to two different
    databases depending on a parameter, i.e., the production database and
    the test database?

    Thanks,
    Todd



    This archive was generated by hypermail 2.0.0 : Mon Aug 02 2004 - 11:04:34 EDT