From 7991f133d53f696b467a77294c5d19b76ea3ec15 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 23 Mar 2004 14:32:28 +0000 Subject: [PATCH] Make createNode smarter about the prototype for the new child node it is about to create. Otherwise, if called on a persistent node, the new child node will be persisted with a possibly bogus id. --- src/helma/objectmodel/db/Node.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index 2bf43df2..d1d0e3fd 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -984,7 +984,19 @@ public final class Node implements INode, Serializable { anon = true; } - Node n = new Node(nm, null, nmgr); + String proto = null; + + // try to get proper prototype for new node + if (dbmap != null) { + DbMapping childmap = anon ? + dbmap.getSubnodeMapping() : + dbmap.getPropertyMapping(nm); + if (childmap != null) { + proto = childmap.getTypeName(); + } + } + + Node n = new Node(nm, proto, nmgr); if (anon) { addNode(n, where);