RE: Specifying PK when creating a new object in DB generated PK mode

From: Scott Anderson (sanderso..irvana.com)
Date: Mon May 05 2008 - 18:07:30 EDT

  • Next message: Scott Anderson: "RE: Query.setRefreshingObjects(boolean)"

    I was looking through my old emails, and I realized that I still haven't
    found a resolution to this. Andrus vaguely mentioned that there might be
    a good reason why you aren't allowed to, but I wasn't able to find that
    reason.

    So, to recap, here's my scenario:

    I am normalizing the schema for a request ticket database. I wrote an
    importer using Cayenne, but I wasn't able to determine how to specify
    the PK for an object when that type is set to have the PK assigned by
    the database.

    The PK is not meaningful (in that its value has no inherent meaning),
    but it is used as the unique token to identify each REQUEST - after all,
    it is the PK - and I therefore must keep this value consistent from one
    schema to the next.

    I need to have the DB generate PKs for the production code when creating
    new requests to avoid PK collision, as we have two replicated MASTER
    servers, one for each country we are located in; the anti-collision
    strategy is to have PKs generated by the database where PK MOD 10 is a
    different value on each MASTER.



    This archive was generated by hypermail 2.0.0 : Mon May 05 2008 - 18:08:30 EDT