I want to add a node under a node using ObjectContentManager.
I am able to add a single node using ObjectContentManager , using
Pojo1 p1 = new Pojo1 ();
p1 .setPath("/p1");
p1 .setName("p_3");
p1 .insert(p1);
ocm.save();
Now under this node I want to add another node of Pojo2 class. I have written a code , but it is giving me exception.
Pojo2 p2 = new Pojo2 ();
p2.setPath("/p1/p2");
p2.setName("p_3");
p2.insert(p2);
ocm.save();
But this is giving me exception.
org.apache.jackrabbit.ocm.exception.ObjectContentManagerException: Cannot create new node of type nt:pojo1 from mapped class class com.sapient.Pojo1; nested exception is javax.jcr.nodetype.ConstraintViolationException: No child node definition for p2 found in node /p1
How i can achieve this? Thanks in advance.