if (rel != null && rel.direction == Relation.DIRECT && !rel.getKeyID(this, p2).equals (nID)) { Key secKey = new DbKey (rel.other, rel.getKeyID(this, p2));
if (rel != null && rel.direction == Relation.DIRECT) { Key secKey = new SyntheticKey (getKey (), propname);
    public void setNode (String propname, INode value) {	// nmgr.logEvent ("setting node prop");	// check if types match, otherwise throw exception	DbMapping nmap = dbmap == null ? null : dbmap.getPropertyMapping (propname);	if (nmap != null && nmap != value.getDbMapping()) {	    if (value.getDbMapping () == null)	        value.setDbMapping (nmap);	    else	        throw new RuntimeException ("Can't set "+propname+" to object with prototype "+value.getPrototype()+", was expecting "+nmap.getTypeName());	}	checkWriteLock ();    	Node n = null;    	if (value instanceof Node)	    n = (Node) value;	else 	    throw new RuntimeException ("Can't add fixed-transient node to a persistent node");	// if the new node is marked as TRANSIENT and this node is not, mark new node as NEW	if (state != TRANSIENT && n.state == TRANSIENT)	    n.makePersistentCapable ();	n.checkWriteLock ();	// check if the main identity of this node is as a named property	// or as an anonymous node in a collection	if (n.parentHandle == null && n.adoptName && !"root".equalsIgnoreCase (n.getPrototype ())) {	    n.setParent (this);	    n.name = propname;	    n.anonymous = false;	    // nmgr.logEvent ("adopted named node: "+n.getFullName ());	} // else nmgr.logEvent ("not adopted: "+n.getFullName ());	if (propMap == null)	    propMap = new Hashtable ();	propname = propname.trim ();	String p2 = propname.toLowerCase ();	Property prop = (Property) propMap.get (p2);	if (prop != null) {	    if (prop.type == IProperty.NODE && n.equals (prop.getNodeValue ())) {	        // nothing to do, just clean up locks and return	        if (state == CLEAN) clearWriteLock ();	        if (n.state == CLEAN) n.clearWriteLock ();	        return;	    }	} else {	    prop = new Property (propname, this);	}	prop.setNodeValue (n);	Relation rel = dbmap == null ? null : dbmap.getPropertyRelation (propname);	if (rel == null || rel.direction == Relation.FORWARD || rel.virtual || rel.other == null || !rel.other.isRelational()) {	    // the node must be stored as explicit property	    propMap.put (p2, prop);	} 	String nID = n.getID();	// check node in with transactor cache	Transactor tx = (Transactor) Thread.currentThread ();	tx.visitCleanNode (new DbKey (nmap, nID), n);	// if the field is not the primary key of the property, also register it	if (rel != null && rel.direction == Relation.DIRECT && !rel.getKeyID(this, p2).equals (nID)) {	    Key secKey = new DbKey (rel.other, rel.getKeyID(this, p2));	    nmgr.evictKey (secKey);	    tx.visitCleanNode (secKey, n);	}	// Server.throwNodeEvent (new NodeEvent (this, NodeEvent.SUBNODE_ADDED, n));	// Server.throwNodeEvent (new NodeEvent (this, NodeEvent.PROPERTIES_CHANGED));	lastmodified = System.currentTimeMillis ();	if (state == CLEAN) markAs (MODIFIED);	if (n.state == DELETED) n.markAs (MODIFIED);    }