String dbAttrName = dbAttr.getName();
if (snapshot.containsKey(dbAttrName)) {
continue;
}
DbAdapter adapter = node.getAdapter();
// skip db-generated... looks like we don't care about the actual PK value
// here, so no need to retrieve db-generated pk back to Java.
if (adapter.supportsGeneratedKeys() && dbAttr.isGenerated()) {
continue;
}
if (autoPkDone) {
throw new CayenneRuntimeException(
"Primary Key autogeneration only works for a single attribute.");
}
// finally, use database generation mechanism
try {
Object pkValue = adapter.getPkGenerator().generatePk(node, dbAttr);
snapshot.put(dbAttrName, pkValue);
autoPkDone = true;
}
catch (Exception ex) {
throw new CayenneRuntimeException("Error generating PK: "