You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by sriraj paul <sr...@yahoo.co.uk> on 2010/09/08 10:01:27 UTC

Create association between nodes without session.save

Hi,

I want to create an association between nodes.

I have the following code
Node testNode=session.getRootNode().addNode("testNode");
Node 
testNode1=testNode.addNode("testNode1","nt:folder");testNode1.addMixin("mix:referenceable");session.save();
 //need to remove thistestNode.setProperty("child1", testNode1);
session.save();
 
This works perfectly fine. But can I do it with just one session.save(); . The 
one given at the end.
 
i.e. if I give the following code it is giving exception.
 
Node testNode=session.getRootNode().addNode("testNode");
Node 
testNode1=testNode.addNode("testNode1","nt:folder");testNode1.addMixin("mix:referenceable");testNode.setProperty("child1",
 testNode1);
session.save();
 
The exception is javax.jcr.ValueFormatException: Target node must be of node 
type mix:referenceable
Can I do it with one session.save() at the end?
 
Thank you
Sriraj
 
 
Exception in thread "main"