RE: Generated ID in 1.2?

From: McDaniel, Joe R. (mcdanij..igr.org)
Date: Tue May 31 2005 - 14:56:20 EDT

  • Next message: Andrus Adamchik: "Re: Generated ID in 1.2?"

    Andrus (or anyone),

    I have tried to work through this but cannot figure a way to get it to
    work.

    I have a table with:
    uniqueId integer unique
    sessionId integer (fk to Session table)
    locusId String

    Where (sessionId and locusId) are the real primary key and uniqueId is
    just used as a shortcut to another table with name/value attributes. I
    do not want all three fields to be the composite PK since there should
    only be one (sessionId, locusId) composite key in existence.

    I thought I might just use the internal PK generation code myself but I
    can't see a way to get to it. I tried setting the uniqueId field to
    "identity" in my Sybase DB but then it is necessary for Cayenne to
    requery to update the contents of the local object to get the generated
    value.

    If "generated" were independent of being primary keys, then this could
    work (I think). Of course, I could just use the longer composite key as
    the reference to the attribute table but Cayenne does not really (seem
    to?) support unique composite keys (although I could test for existence
    and create if not present...)

    Any suggestions?

    Best,

    Joe

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: Wednesday, May 25, 2005 3:52 PM
    To: cayenne-use..bjectstyle.org
    Subject: RE: Generated ID in 1.2?

    > Hi Andrus,
    >
    > OK -- I did not check this field as a PK since I was trying to have a
    > composite PK with the generated PK being used for references. I can
    > create what I want in code by checking for duplicates of the composite
    > fields but if I make all three fields PKs then there will always be a
    > unique key no matter how many duplicates of the composite key(s)
    > exist....
    >
    >
    > I'll think about what I am doing to see if there is a way to bend this
    > into your design so far.
    >
    > Best,
    >
    > Joe

    "PK" and "Generated" checkboxes are NOT mutually exclusive. So if a
    column
    is a part of a composite PK it has to be setup as such, regardless
    whether
    it is an object attribute or not. So I don't think you need to "bend"
    anything - Cayenne should wrk fine with composite keys.

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue May 31 2005 - 14:56:22 EDT