From 78d647f5211f8c9f98e6858f93e8c50c434b2b88 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 8 Mar 2005 11:46:15 +0000 Subject: [PATCH] Implement HopObject.persist() to store HopObjects to db without adding them to any collections. --- src/helma/objectmodel/db/Node.java | 7 +++++++ src/helma/scripting/rhino/HopObject.java | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index 5329074e..3285bf70 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -2410,6 +2410,13 @@ public final class Node implements INode, Serializable { return (dbmap != null) && dbmap.isRelational(); } + /** + * Public method to make a node persistent. + */ + public void persist() { + makePersistable(); + } + /** * Turn node status from TRANSIENT to NEW so that the Transactor will * know it has to insert this node. Recursively persistifies all child nodes diff --git a/src/helma/scripting/rhino/HopObject.java b/src/helma/scripting/rhino/HopObject.java index 27886abb..3d97bef1 100644 --- a/src/helma/scripting/rhino/HopObject.java +++ b/src/helma/scripting/rhino/HopObject.java @@ -642,6 +642,19 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco return false; } + /** + * Makes the HopObject and all its reachable descendants persistent. + * + * @return the ID of the newly persisted HopObject or null if operation failed + */ + public Object jsFunction_persist() { + if (node instanceof helma.objectmodel.db.Node) { + ((helma.objectmodel.db.Node) node).persist(); + return node.getID(); + } + return null; + } + /** * Invalidate the node itself or a subnode */