On Dec 11, 2007, at 3:05 PM, Kevin Menard (JIRA) wrote:
> However, when using the default key, calling
> ObjRelationship#getMapKey() returns null. Is that expected behavior
> as well? If so, I think I'd like to see that changed. I'm fine
> with defaults not being specified in the DataMap, but the runtime
> model should have all the info.
Yes this is expected behavior. What NULL means is simply that there is
no ObjAttribute for the key. Since id's in Cayenne are not class
properties by default, there's nothing to map to. Here is the logic to
extract the key in runtime:
IdMapKeyAccessor.java:
ObjectId id = ((Persistent) object).getObjectId();
if (id.isTemporary()) {
return id;
}
Map map = id.getIdSnapshot();
if (map.size() == 1) {
Map.Entry pkEntry = (Map.Entry)
map.entrySet().iterator().next();
return pkEntry.getValue();
}
return id;
So you see, there is a bit of fuzziness - a key can be an ObjectId for
multi-column PK and for NEW objects, or it can be a single PK value
for committed single-column PK.
Andrus
This archive was generated by hypermail 2.0.0 : Tue Dec 11 2007 - 08:26:01 EST