try
{
tx = _kit.getTransaction(_conn);
tx.begin();
ProductGroupWithCollectionProxy pg = new ProductGroupWithCollectionProxy();
pg.setId(new Integer(77777));
pg.setName("1");
_conn.makePersistent(pg);
tx.commit();
Identity oid = _conn.getIdentity(pg);
// get from the database
tx = _kit.getTransaction(_conn);
tx.begin();
_conn.invalidate(oid);
pg = (ProductGroupWithCollectionProxy) _conn.getObjectByIdentity(oid);
assertTrue("CollectionProxy isn't loaded",
!((CollectionProxyDefaultImpl) pg.getAllArticlesInGroup()).isLoaded());
Article article = Article.createInstance();
article.setArticleId(new Integer(77777));
article.setProductGroup(pg);
article.setStock(333);
article.setArticleName("333");
pg.getAllArticlesInGroup().add(article);
_conn.makePersistent(article);
tx.commit();
// get from the database
tx = _kit.getTransaction(_conn);
tx.begin();
_conn.invalidate(oid);
pg = (ProductGroupWithCollectionProxy) _conn.getObjectByIdentity(oid);
assertEquals("CollectionProxy size", 1, pg.getAllArticlesInGroup().size());
((InterfaceArticle) pg.getAllArticlesInGroup().get(0)).setArticleName("444");
tx.commit();
// test isolation of the cache
((InterfaceArticle) pg.getAllArticlesInGroup().get(0)).setArticleName("555");
tx = _kit.getTransaction(_conn);
tx.begin();
pg = (ProductGroupWithCollectionProxy) _conn.getObjectByIdentity(oid);
assertEquals("Article name", "444",
((InterfaceArticle) pg.getAllArticlesInGroup().get(0)).getArticleName());
tx.commit();
try
{
tx = _kit.getTransaction(_conn);
tx.begin();
pg = (ProductGroupWithCollectionProxy) _conn.getObjectByIdentity(oid);
_conn.deletePersistent(pg.getAllArticlesInGroup().get(0));
_conn.deletePersistent(pg);
tx.commit();
}
catch (Throwable ex)
{