Key ownerKey = null;
try {
EmbeddedCollectionOwner owner = new EmbeddedCollectionOwner();
EmbeddedRelatedBase baseRel1 = new EmbeddedRelatedBase("First Base", 100);
owner.addChild(baseRel1);
EmbeddedRelatedSub subRel2 = new EmbeddedRelatedSub("Second Base", 200, "Other Type");
owner.addChild(subRel2);
pm.currentTransaction().begin();
pm.makePersistent(owner);
pm.currentTransaction().commit();