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
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
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
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
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
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
//