Re: UUID as primary key

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

  • Next message: Andrus Adamchik: "Re: UUID as primary key"

    On 7/12/06, Gentry, Michael (Contractor) <michael_gentr..anniemae.com> wrote:
    > You could override setPersistenceState() in your Treatment class:
    >
    > public void setPersistenceState(int state)
    > {
    > super.setPersistenceState(state);
    >
    > // If object was just created, set PK
    > if (state == PersistenceState.NEW)
    > setId(UUID.randomUUID());
    > }

    Hmmm... I tried that, but setPersistanceState() is invoked multilple
    times with state=NEW and thus I'm changing the UUID each time. That
    can't be right.

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



    This archive was generated by hypermail 2.0.0 : Thu Jul 13 2006 - 12:33:01 EDT