// --------------------------------------------------------------------------------
A a = new A();
a.setPath("/test");
a.setA1("a1");
a.setA2("a2");
B b = new B();
b.setB1("b1");
b.setB2("b2");
a.setB(b);
C c1 = new C();
c1.setId("first");
c1.setName("First Element");
C c2 = new C();
c2.setId("second");
c2.setName("Second Element");
C c3 = new C();
c3.setId("third");
c3.setName("Third Element");
Collection collection = new ArrayList();
collection.add(c1);
collection.add(c2);
collection.add(c3);
a.setCollection(collection);
ocm.insert(a);
ocm.save();
// --------------------------------------------------------------------------------
// Get the object
// --------------------------------------------------------------------------------
a = (A) ocm.getObject( "/test");
assertNotNull("a is null", a);
assertTrue("Incorrect a1", a.getA1().equals("a1"));
assertNotNull("a.b is null", a.getB());
assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("b1"));
assertNotNull("a.collection is null", a.getCollection());
assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
// --------------------------------------------------------------------------------
// Update the object
// --------------------------------------------------------------------------------
a.setA1("new value");
B newB = new B();
newB.setB1("new B1");
newB.setB2("new B2");
a.setB(newB);
ocm.update(a);
ocm.save();