Re: Obtain primary key for DataObject before commitChanges

2015-08-10 Thread Mike Kienenberger
Not sure if it's clear, but there are two different approaches to your problem described. 1) You can set a foreign relationship to your audit table and let Cayenne assign the key at commit. This is probably the easiest especially if you dynamically create the relationships in java code. Except

Re: Obtain primary key for DataObject before commitChanges

2015-08-10 Thread Mike Kienenberger
I set up auditing using a different approach in one project many years ago back in Cayenne 1.1, and I've continued using it up to this point in 3.x. I generated special setter, addTo, and removeFrom methods as well as a create method which created the logger object at that point. To get the

Obtain primary key for DataObject before commitChanges

2015-08-10 Thread Hugi Thordarson
Hi all. 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). Cheers, - hugi

Re: Obtain primary key for DataObject before commitChanges

2015-08-10 Thread Aristedes Maniatis
On 10/08/2015 8:31pm, Hugi Thordarson wrote: 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

Re: Obtain primary key for DataObject before commitChanges

2015-08-10 Thread Hugi Thordarson
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

Re: Obtain primary key for DataObject before commitChanges

2015-08-10 Thread Hugi Thordarson
Thanks Mike! Although the approach I’m working on is a little different (and meant to be reusable with any Cayenne installation so can’t depend on superclass template modifications), it’s very helpful to see code from other Cayenne folks. Cheers, - hugi // Hugi Thordarson //