cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Øyvind Harboe" <oyvind.har...@zylin.com>
Subject Re: UUID as primary key
Date Thu, 13 Jul 2006 16:32:38 GMT
On 7/12/06, Gentry, Michael (Contractor) <michael_gentry@fanniemae.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

Mime
View raw message