Despite the fact that it's called a "meaningless primary key", I would like 
to programmically determine the value of each entity's primary key.   
One way for me to do this is to generate a primaryKey() method in my class 
generation template, but I'd rather use the framework if possible.
It seems like the way to do this is:
                Class objEntityClass = aCayenneDataObject.getObjectId().getObjClass();
and from there:
                DbEntity aDbEntityClass = objEntityClass.getDbEntity();
Are these intended for "user" access, or only internal framework use?
Actually, maybe I'll explain the usage first in case there's an easier way 
to do this in Cayenne.
======
I have business requirements to log all database changes (record creation, 
deletion, modification) to a ChangeLog table (except, of course, the 
ChangeLog changes).  My template creates setAndLogX(CustomLoggingData, 
value) methods for every setX(value) method (and generally marks setX(value) 
private or protected as allowed by the framework).  The setAndLogX() method 
calls setX(value) and then creates a ChangeLog record.
My changelog table contains
ChangeLog_ID (meaningless primary key)
Entity,
Attribute,
Old Value,
New Value,
Modification Date,
foreignRecordKey
CustomLoggingData
All of my non-read-only entities have a single integer meaningless primary 
key.
foreignRecordKey is the primary key of the table/field change which we're 
logging.
In WebObjects, I could pull out all of the information out of the model 
representation.
In Toplink, I could pull most of it out of the model, and the rest out of 
hardcoded template-generated code.
In WebObjects, I could also create a one-to-one relationship for each 
foreignKey while in Toplink I had to manually look up the primary key and 
set the foreignRecordKey value.
======
In addition, there are a couple of Entities where the primary key is used as 
an identifier.
For each user object, we output to a log the username and primary key of the 
user object.
For each paymentHistory object, we send the paymentHistory primary key to 
our processing gateway as an invoice number.
Thanks,
-Mike
This archive was generated by hypermail 2.0.0 : Mon Sep 08 2003 - 17:05:31 EDT