making nodes transient that do have child nodes should now

work, because loadnodes no longer throws the existing nodes
away to see if there are some in the database.
dump stack traces on getKey and getID for transient nodes.
This commit is contained in:
hns 2001-08-13 17:04:07 +00:00
parent 2b574f11fa
commit 55e58ab509

View file

@ -410,8 +410,10 @@ public final class Node implements INode, Serializable {
*/ */
public String getID () { public String getID () {
if (state == TRANSIENT) if (state == TRANSIENT) {
Thread.dumpStack ();
throw new RuntimeException ("getID called on transient Node: "+this); throw new RuntimeException ("getID called on transient Node: "+this);
}
return id; return id;
} }
@ -536,8 +538,10 @@ public final class Node implements INode, Serializable {
} }
public Key getKey () { public Key getKey () {
if (state == TRANSIENT) if (state == TRANSIENT) {
Thread.dumpStack ();
throw new RuntimeException ("getKey called on transient Node: "+this); throw new RuntimeException ("getKey called on transient Node: "+this);
}
if (dbmap == null && prototype != null && nmgr != null) if (dbmap == null && prototype != null && nmgr != null)
dbmap = nmgr.getDbMapping (prototype); dbmap = nmgr.getDbMapping (prototype);
if (primaryKey == null) if (primaryKey == null)
@ -1178,6 +1182,10 @@ public final class Node implements INode, Serializable {
* ID index or the actual nodes. * ID index or the actual nodes.
*/ */
protected void loadNodes () { protected void loadNodes () {
// Don't do this for transient nodes which don't have an explicit subnode relation set
if ((state == TRANSIENT || state == NEW) && subnodeRelation == null)
return;
DbMapping smap = dbmap == null ? null : dbmap.getSubnodeMapping (); DbMapping smap = dbmap == null ? null : dbmap.getSubnodeMapping ();
if (smap != null && smap.isRelational ()) { if (smap != null && smap.isRelational ()) {
// check if subnodes need to be reloaded // check if subnodes need to be reloaded
@ -1647,9 +1655,9 @@ public final class Node implements INode, Serializable {
prop.nhandle = new NodeHandle (new DbKey (n.getDbMapping (), kval, rel.getRemoteField ())); prop.nhandle = new NodeHandle (new DbKey (n.getDbMapping (), kval, rel.getRemoteField ()));
} }
String nID = n.getID(); if (n.state != TRANSIENT) {
// check node in with transactor cache // check node in with transactor cache
String nID = n.getID();
Transactor tx = (Transactor) Thread.currentThread (); Transactor tx = (Transactor) Thread.currentThread ();
tx.visitCleanNode (new DbKey (nmap, nID), n); tx.visitCleanNode (new DbKey (nmap, nID), n);
// if the field is not the primary key of the property, also register it // if the field is not the primary key of the property, also register it
@ -1658,6 +1666,7 @@ public final class Node implements INode, Serializable {
nmgr.evictKey (secKey); nmgr.evictKey (secKey);
tx.visitCleanNode (secKey, n); tx.visitCleanNode (secKey, n);
} }
}
lastmodified = System.currentTimeMillis (); lastmodified = System.currentTimeMillis ();
if (n.state == DELETED) n.markAs (MODIFIED); if (n.state == DELETED) n.markAs (MODIFIED);
@ -1781,7 +1790,6 @@ public final class Node implements INode, Serializable {
Transactor current = (Transactor) Thread.currentThread (); Transactor current = (Transactor) Thread.currentThread ();
current.visitNode (this); current.visitNode (this);
current.visitCleanNode (this); current.visitCleanNode (this);
}
for (Enumeration e = getSubnodes (); e.hasMoreElements (); ) { for (Enumeration e = getSubnodes (); e.hasMoreElements (); ) {
Node n = (Node) e.nextElement (); Node n = (Node) e.nextElement ();
if (n.state == TRANSIENT) if (n.state == TRANSIENT)
@ -1796,6 +1804,7 @@ public final class Node implements INode, Serializable {
} }
} }
} }
}
/** /**