Re: UUID as primary key

From: Øyvind Harboe (oyvind.harbo..ylin.com)
Date: Thu Jul 13 2006 - 12:32:14 EDT

  • Next message: Øyvind Harboe: "Re: UUID as primary key"

    On 7/12/06, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > Yes, there are a few ways of doing this. The cleanest one is this:
    >
    > object.getObjectId().getReplacementIdMap().put(Treatment.BLA_BLA_PK,
    > UUID.randomUUID());

    Thanks! Works great AFAICT.

    Note that I had to remove the pk ObjAttribute as it is a required
    DbAttribute and causes a validation failure if I don't remove it.

    > BTW, this code can be added to "setPersistenceState()" to be executed
    > when persistence state is changed to NEW.

    I'm not comfortable with this, because the UUID should only be set
    once and I haven't figured out how to tell when to execute the code
    above if I override setPersistenceState().

    -- 
    Øyvind Harboe
    http://www.zylin.com
    



    This archive was generated by hypermail 2.0.0 : Thu Jul 13 2006 - 12:32:40 EDT