Re: Using a custom PK Table

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jul 26 2005 - 16:12:03 EDT

  • Next message: Andrus Adamchik: "Re: Delete Rule Error"

    To add to what Mike wrote, JdbcAdapter (superclass of all standard
    DbAdapters) has a method "setPkGenerator", so you can provide a custom
    PkGenerator for any existing adapter.

    Andrus

    > Albert Jagnow <albert-jagno..iowa.edu> wrote:
    >> I am working on a web version of an application that uses the same data
    >> as a legacy RPG application. The PK values for the tables come from a
    >> table with columns for table name and last used PK value. The legacy
    >> RPG application is adding records at the same time I am adding records
    >> from the web application. In my testing I have run into some problems
    >> with conflicting PK values. I was using DataObjectUtils.objectForPK
    >> passing in the table name to obtain the next PK value for the table, but
    >> this appears to not always grab the most current data from the table.
    >> What is the best method to quickly get and update the next PK value?
    >> Also does cayenne have the ability to use a PK delegate like in
    >> WebObjects, that will call my custom PK generation method for a given
    >> entity automatically when the data is to be written to the database?
    >
    > If you take a look at DbAdaptor, you can create a subclass of your adaptor
    > and provide an alternate generator.
    > It's pretty simple to do. The standard auto pk generation is very
    > similar
    > to both webobjects and to the RPG code you've describe, so it'd probably
    > just be a matter of providing a different table and column nameset.
    >
    > -Mike
    >



    This archive was generated by hypermail 2.0.0 : Tue Jul 26 2005 - 16:12:03 EDT