Entities whose pk values come from a value in another mysql table

From: Scott Ellsworth (scot..lodar.com)
Date: Mon Apr 05 2004 - 21:48:32 EDT

  • Next message: Mike Kienenberger: "Re: Entities whose pk values come from a value in another mysql table"

    Hi, all.

    We have a schema that was designed before MySql supported autonumbers,
    so we rolled our own uid pk generation. It is in use by a lot of
    different apps, and cannot easily be changed, and further, the older
    deployed apps must continue to work, so the uid sequence must be
    updated too.

    There are several hundred tables created with sql like:

    CREATE TABLE Resource (
             id INTEGER NOT NULL,
             resource_type INTEGER,
             max_reads INTEGER,
             reads_reserved INTEGER,
             is_reserved_for_modify CHAR(2),
             state INTEGER,
             barcode VARCHAR(255)
    );
    ALTER TABLE Resource ADD PRIMARY KEY
             (id);
    CREATE TABLE Resource_Seq (
            nextval INTEGER NOT NULL
    );
    INSERT INTO Resource_Seq (nextval) values (1);

    Each new entry into Resource gets an id equal to Resource_Seq.nextval,
    which is incremented as soon as it is read. (This thus emulates an
    Oracle sequence, with a bit more effort because of the key management.)

    Is there a way to tell Cayenne to do this kind of key management?
    Pointers to examples like this would work. I am targeting Cayenne 1.1.

    Scott



    This archive was generated by hypermail 2.0.0 : Mon Apr 05 2004 - 21:48:22 EDT