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:14 GMT
On 7/12/06, Andrus Adamchik <andrus@objectstyle.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

Mime
View raw message