{
AddressCouchMTO address = new AddressCouchMTO();
address.setAddressId("a");
address.setStreet("sector 11");
PersonCouchMTO person1 = new PersonCouchMTO();
person1.setPersonId("1");
person1.setPersonName("Kuldeep");
PersonCouchMTO person2 = new PersonCouchMTO();
person2.setPersonId("2");
person2.setPersonName("vivek");
person1.setAddress(address);
person2.setAddress(address);
em.persist(person1);
em.persist(person2);
em = getNewEM();
PersonCouchMTO foundPerson1 = em.find(PersonCouchMTO.class, 1);
Assert.assertNotNull(foundPerson1);
Assert.assertNotNull(foundPerson1.getAddress());
Assert.assertEquals("1", foundPerson1.getPersonId());
Assert.assertEquals("Kuldeep", foundPerson1.getPersonName());
Assert.assertEquals("a", foundPerson1.getAddress().getAddressId());
Assert.assertEquals("sector 11", foundPerson1.getAddress().getStreet());
PersonCouchMTO foundPerson2 = em.find(PersonCouchMTO.class, 2);
Assert.assertNotNull(foundPerson2);
Assert.assertNotNull(foundPerson2.getAddress());
Assert.assertEquals("2", foundPerson2.getPersonId());
Assert.assertEquals("vivek", foundPerson2.getPersonName());
Assert.assertEquals("a", foundPerson2.getAddress().getAddressId());
Assert.assertEquals("sector 11", foundPerson2.getAddress().getStreet());
foundPerson1.setPersonName("KK");
foundPerson2.setPersonName("vives");
em.merge(foundPerson1);
em.merge(foundPerson2);
em = getNewEM();
foundPerson1 = em.find(PersonCouchMTO.class, 1);
Assert.assertNotNull(foundPerson1);
Assert.assertNotNull(foundPerson1.getAddress());
Assert.assertEquals("1", foundPerson1.getPersonId());
Assert.assertEquals("KK", foundPerson1.getPersonName());
Assert.assertEquals("a", foundPerson1.getAddress().getAddressId());
Assert.assertEquals("sector 11", foundPerson1.getAddress().getStreet());
foundPerson2 = em.find(PersonCouchMTO.class, 2);
Assert.assertNotNull(foundPerson2);
Assert.assertNotNull(foundPerson2.getAddress());
Assert.assertEquals("2", foundPerson2.getPersonId());
Assert.assertEquals("vives", foundPerson2.getPersonName());
Assert.assertEquals("a", foundPerson2.getAddress().getAddressId());
Assert.assertEquals("sector 11", foundPerson2.getAddress().getStreet());
em.remove(foundPerson1);
em.remove(foundPerson2);
foundPerson1 = em.find(PersonCouchMTO.class, 1);