// Creating other objects
Gallery metropolitan = objContext.newObject(Gallery.class);
metropolitan.setName("Metropolitan Museum of Art");
Painting girl = objContext.newObject(Painting.class);
girl.setName("Girl Reading at a Table");
Painting stein = objContext.newObject(Painting.class);
stein.setName("Gertrude Stein");
// connecting objects together via relationships
picasso.addToPaintings(girl);
picasso.addToPaintings(stein);
girl.setGallery(metropolitan);
stein.setGallery(metropolitan);
// saving all the changes above
objContext.commitChanges();
}