Re: Writing a PostgreSQL plugin

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Jan 22 2003 - 18:17:30 EST

  • Next message: Andrus: "Cayenne Operations Sorters"

    >
    > Are there some guidelines about how to approach writing a new JDBC
    > plugin for a specific DB, or is it a completely different process every
    > time? If not (hopefully), what might be the best way to start?
    >

    There are definitely guidelines, but no answer that fits all cases. This
    is the reason why User Guide Section 4.6.2 is still waiting to be written
    :-). Anyway, let me try.

    The process:

    1. Creates a subpackage under org.objectstyle.cayenne.dba.postgres. [This
    is already done]

    2. Create JdbcAdpater subclass in this package [This is already done:
    PostgresAdapter].

    3. Reimplement all superclass methods that should work differently (for
    instance methods returning DDL SQL statements)

    4. Run Cayenne unit tests suite with the new adapter, and see where it
    fails. Continue with Step 2 untill all unit tests pass (though, see note
    (b) below). General idea is to override only those parts of default
    implementation that need overriding.

    Things to keep in mind:

    a. Define what primary key mechanism fits the best. (Oracle - sequences,
    Sybase - stored procedures, PostgreSQL - ?). Default mechanism
    (select/insert from AUTO_PK_TABLE) is not transactional. Maybe use
    pessimistic locking: "select for update"? Based on the decision made
    override "createPkGenerator" to return a custom subclass of
    JdbcPkGenerator

    b. Certain database peculiarities may not be described well enough by the
    current generic DbAdapter/PkGenerator API. This may be the biggest
    stumbling block in the whole porting effort. In this case, changes to
    DbAdapter API will be discussed on this list and we incorporate this in
    the basic API.

    c. CayenneModeler integration. As of now, the list of adapters is
    hardcoded in the modeler (we need to make it more dynamic in the future).
    So a new adapter need to be added to the list (I believe Postgres is there
    but commented out)

    d. For postgres only (can wait till later) - fix Ant build scripts to stop
    ignoring postgres package when generating API docs.

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Jan 22 2003 - 18:17:32 EST