Re: Old web application needs a second database

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon May 03 2010 - 07:44:37 EDT

  • Next message: Borut Bolčina: "Re: Old web application needs a second database"

    "Default" refers to a "default domain" within a single configuration
    instance. You will be working with 2 configuration instances, so both
    will have a "default domain". This also means that your old code can
    stay unchanged, while the new application won't be able to use a
    static method for DataContext creation (either with domain name or
    without it). Instead you will need to write your own factory method
    that gets a hold of "conf", gets its default domain, and creates a
    context from it.

    Andrus

    On May 3, 2010, at 2:26 PM, Borut Bolčina wrote:

    > Hello,
    >
    > Our old large web application uses one database and there are a
    > large number
    > of DataContext.createDataContext(); statements all over the web
    > application
    > itself and jars it depends on.
    >
    > Now there is a need to access another database. Currently the
    > Configuration
    > gets initialized with the first call of createDataContext - there is
    > no
    > special class which initializes cayenne eagerly. All defaults.
    >
    > Reading the API (
    > http://cayenne.apache.org/doc30/api/org/apache/cayenne/access/DataContext.html#createDataContext%28%29)
    > there is a sentence:
    >
    > "Factory method that creates and returns a new instance of
    > DataContext based
    > on default domain."
    >
    > What is the default domain? I can't find anything in the modeler or
    > in the
    > cayenne xml configuration file to mark one node as default.
    >
    > Currently the cayenne.xml comes from one of the external jars, not
    > the web
    > application itself. Now I will have to create a manually crafted
    > my-cayenne.xml configuration file which has another data node and
    > initialize
    > it with something like:
    >
    > DefaultConfiguration conf = new DefaultConfiguration("my-
    > cayenne.xml");
    >
    > But I suspect I would have to find all occurances of
    > createDataContext() and
    > replace it with createDataContext("old-node-name"). I would really
    > like to
    > avoid that!
    >
    > Instead, can I just leave the access code to "old" database as is
    > and only
    > create data context for the new database with
    > createDataContext("my-new-node-name")?
    >
    > -Borut



    This archive was generated by hypermail 2.0.0 : Mon May 03 2010 - 07:45:18 EDT