Set<AddressU1M> addressess = new HashSet<AddressU1M>();
addressess.add(address1);
addressess.add(address2);
PersonU1M p1 = new PersonU1M();
p1.setPersonName("vivek");
p1.setPersonId("1");
p1.setAddresses(addressess);
em.persist(p1);
PersistenceDelegator delegator = CoreTestUtilities.getDelegator(em);
Map<String, Object> relationMap = null;
EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(
((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), PersonU1M.class);
CoreTestEntityReader reader = new CoreTestEntityReader(kunderaMetadata);
p1.setAddresses(null);
reader.recursivelyFindEntities(p1, relationMap, metadata, delegator, false);
Assert.assertNotNull(p1.getAddresses());
Assert.assertTrue(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
// p1.setAddresses(null);
reader.recursivelyFindEntities(p1, relationMap, metadata, delegator, true);
Assert.assertNotNull(p1.getAddresses());
Assert.assertFalse(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
}