You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Øyvind Harboe <oy...@zylin.com> on 2006/08/01 13:23:26 UTC

Re: UUID as primary key

On 7/22/06, Andrus Adamchik <an...@objectstyle.org> wrote:
>
> I see. That makes sense - each DataContext in a nested context chain
> would create its own instance of object and transition it through the
> lifecycle. So technically it is still called once per object
> instance. However the fact that ID can be passed from a peer object
> in the upstream context requires an extra check. E.g.:
>
>   public void setPersistenceState(int state) {
>     super.setPersistenceState(state);
>
>     if (state == PersistenceState.NEW && getObjectId() == null) {
>       setId(UUID.randomUUID());
>     }
>   }


That didn't work for me. getObjectId()  is never null when
setPersistanceState() is called, AFAICT.

Otherwise, it seems to work fine though.



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