public void addObjectToCache(Object obj, Node node, XMLMapping selfRecordMapping) {
// Can't process non-element nodes
if (node.getNodeType() != Node.ELEMENT_NODE) {
return;
}
AbstractSession session = context.getSession(obj);
XMLDescriptor xmlDescriptor = (XMLDescriptor)session.getDescriptor(obj);
DOMRecord row = new DOMRecord((Element)node);
row.setSession(session);
Vector pk = xmlDescriptor.getObjectBuilder().extractPrimaryKeyFromRow(row, session);
if (xmlDescriptor.shouldPreserveDocument() || xmlDescriptor.getPrimaryKeyFieldNames().size() > 0) {
if ((pk == null) || (pk.size() == 0)) {
pk = new Vector();
pk.addElement(new WeakObjectWrapper(obj));
}
CacheKey key = session.getIdentityMapAccessorInstance().acquireDeferredLock(pk, xmlDescriptor.getJavaClass(), xmlDescriptor);
if ((xmlDescriptor).shouldPreserveDocument()) {
key.setRecord(row);
}
key.setObject(obj);
key.releaseDeferredLock();