Re: Using a custom PK Table

From: Mike Kienenberger (mkienen..laska.net)
Date: Mon Jul 25 2005 - 13:08:32 EDT

  • Next message: Joseph Hannon: "Re: How do I use the Modeler to define a non key field as unique?"

    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 : Mon Jul 25 2005 - 13:05:21 EDT