On 7/13/06, Andrus Adamchik <[EMAIL PROTECTED]> wrote:
On Jul 13, 2006, at 12:32 PM, Øyvind Harboe wrote:
> On 7/12/06, Gentry, Michael (Contractor)
> <[EMAIL PROTECTED]> 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.
No it can't - it should only be invoked once per object.
Note that my object is in a child context when I perform a commit.
--
Øyvind Harboe
http://www.zylin.com