n.name = propname;
n.setName(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.getExactPropertyMapping(propname);        if ((nmap != null) && (nmap != value.getDbMapping())) {            if (value.getDbMapping() == null) {                value.setDbMapping(nmap);            } else if (!nmap.isStorageCompatible(value.getDbMapping())) {                throw new RuntimeException("Can't set " + propname +                                           " to object with prototype " +                                           value.getPrototype() + ", was expecting " +                                           nmap.getTypeName());            }        }        if (state != TRANSIENT) {            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.makePersistable();        }        if (state != TRANSIENT) {            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 != this && !"root".equalsIgnoreCase(n.getPrototype())) {            // avoid calling getParent() because it would return bogus results            // for the not-anymore transient node            Node nparent = (n.parentHandle == null) ? null                                                    : n.parentHandle.getNode(nmgr);            // if the node doesn't have a parent yet, or it has one but it's            // transient while we are persistent, make this the nodes new parent.            if ((nparent == null) ||               ((state != TRANSIENT) && (nparent.getState() == TRANSIENT))) {                n.setParent(this);                n.name = propname;                n.anonymous = false;            }        }        propname = propname.trim();        String p2 = propname.toLowerCase();        Relation rel = (dbmap == null) ? null : dbmap.getPropertyRelation(propname);        if (rel != null && (rel.countConstraints() > 1 || rel.isComplexReference())) {            rel.setConstraints(this, n);            if (rel.isComplexReference()) {                Key key = new MultiKey(n.getDbMapping(), rel.getKeyParts(this));                nmgr.nmgr.registerNode(n, key);                return;            }        }        Property prop = (propMap == null) ? null : (Property) propMap.get(p2);        if (prop != null) {            if ((prop.getType() == IProperty.NODE) &&                    n.getHandle().equals(prop.getNodeHandle())) {                // 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);        if ((rel == null) ||                rel.reftype == Relation.REFERENCE ||                state == TRANSIENT ||                rel.otherType == null ||                !rel.otherType.isRelational()) {            // the node must be stored as explicit property            if (propMap == null) {                propMap = new Hashtable();            }            propMap.put(p2, prop);            if (state == CLEAN) {                markAs(MODIFIED);            }        }        // don't check node in transactor cache if node is transient -        // this is done anyway when the node becomes persistent.        if (n.state != TRANSIENT) {            // check node in with transactor cache            Transactor tx = (Transactor) Thread.currentThread();            // tx.visitCleanNode (new DbKey (dbm, nID), n);            // UPDATE: using n.getKey() instead of manually constructing key. HW 2002/09/13            tx.visitCleanNode(n.getKey(), n);            // if the field is not the primary key of the property, also register it            if ((rel != null) && (rel.accessName != null) && (state != TRANSIENT)) {                Key secKey = new SyntheticKey(getKey(), propname);                nmgr.evictKey(secKey);                tx.visitCleanNode(secKey, n);            }        }        lastmodified = System.currentTimeMillis();        if (n.state == DELETED) {            n.markAs(MODIFIED);        }    }