Re: Switching databases

From: Michael Gentry (mgentr..asslight.net)
Date: Wed Mar 24 2010 - 11:08:22 EDT

  • Next message: John Armstrong: "AUTO_PK_SUPPORT, mysql and join tables"

    As long as you are using one of the standard PK generation schemes
    supported by Cayenne, you don't have to roll your own. If you want to
    do something special, like use a GUID type column that you calculate,
    then you'd have to create your own for that. I'm not sure if there is
    more detailed documentation (I don't recall any), but it is fairly
    simple to do now. Under the DataNode's Adapter tab in CM, you can
    specify a custom DbAdapter (subclass one of the Cayenne ones) and
    override the PK generator portions to use your custom PK generator. A
    friend of mine fairly new to Cayenne did this in less than an hour to
    generate his GUID values.

    mrg

    On Wed, Mar 24, 2010 at 10:54 AM, <MGargan..scholar.com> wrote:
    > Thanks everyone.  This is definitely making me feel more comfortable with
    > Cayenne as an ORM choice.  For #2 (PK Generation) below, does that mean I
    > have to roll my own generator?  Is there more detailed documentation on
    > that (don't see it on the website)?
    >
    > Thanks again.
    > -Mike
    >
    >
    >
    >
    > From:
    > Andrus Adamchik <andru..bjectstyle.org>
    > To:
    > use..ayenne.apache.org
    > Date:
    > 03/24/2010 08:16 AM
    > Subject:
    > Re: Switching databases
    >
    >
    >
    > Cayenne project mapping is close to a 100% portable between different
    > DB's as long as the DB's themselves are compatible. I guess the only
    > piece that will need to change is DataNode connection info (and this
    > can be delegated to container by using JNDI node).
    >
    > Now specific items:
    >
    > 1. DbAdapter:
    > Analog of Hibernate's dialect in Cayenne is DbAdapter. Cayenne has
    > auto-detection of the DB type, so the correct DbAdapter is installed
    > automatically. No need to change anything.
    >
    > 2. PK generation:
    > Auto ID generation mechanism may differ between DBs. It has to be
    > installed on the target DB either manually before starting the app, or
    > with some simple Cayenne code using DbGenerator class on startup. In
    > any event, the differences between DB's are still abstracted and won't
    > require mapping changes. E.g. for Oracle DbGenerator will create PK
    > sequences, while for MySQL - a PK lookup table.
    >
    > 3. Stored procedures:
    > generally mappings should be portable, however different DB's may have
    > incompatible formats for handling in/out parameters and returned
    > result sets. So let's look at specific cases for me to comment more
    > intelligently.
    >
    > Hope this helps.
    >
    > Andrus
    >
    >
    > On Mar 23, 2010, at 8:40 PM, MGargan..scholar.com wrote:
    >> Hi,
    >>
    >>        I'm looking into using Cayenne as a backend ORM technology
    >> replacing hibernate.  Currently our product supports multiple DBMSes
    >> (SQL
    >> Server, Oracle, DB2) depending on what the client already has
    >> installed.
    >> In hibernate when switching between oracle and sql server, for
    >> example, is
    >> just a matter of changing the dialect.  Is there a recommended way in
    >> Cayenne to generate models in a generic way so that the backend DBMS
    >> can
    >> be swapped out in code?  (How is auto id generation effected?  How are
    >> stored procs. handled?  etc.)  I only see articles related to running
    >> across multiple DBMSes.
    >>
    >> Thanks.
    >> -Mike
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Mar 24 2010 - 11:09:16 EDT