>> Is it possible for me to obtain the primary key for a Cayenne DataObject 
>> before committing changes? I’m writing an audit log and I need the key for 
>> the object during PrePersist (where I’m constructing the log object).
> 
> How will it have a primary key before the record is written to the database? 
> Or do you want to hang onto the temporary ObjectId and then replace it with 
> the real PK after the commit?

Well, in EOF (to mention that old chap yet again) I invoked permanentGlobalID() 
on the object. That meant that if the object had a temporary GlobalID, it would 
make a roundtrip to the DB and assign a permanent ID without actually saving 
the object.

But I realized I’m actually going about this the wrong way. If I do the logging 
in PostPersist rather than PrePersist, the object already has a permanent ID, 
so no premature PK generation is required :).

Thanks,
- hugi

Reply via email to