}
public void testDeepCascadeDelete ()
{
CascadesEntity ent = new CascadesEntity ();
CascadesEntity rel1 = new CascadesEntity ();
CascadesEntity rel2 = new CascadesEntity ();
CascadesEntity depend = new CascadesEntity ();
CascadesEntity deep1 = new CascadesEntity ();
CascadesEntity deep2 = new CascadesEntity ();
CascadesEntity deep3 = new CascadesEntity ();
ent.setAll (rel1);
rel1.setAll (deep1);
ent.getAllCollection ().add (rel2);
rel2.getAllCollection ().add (deep2);
ent.setDependent (depend);
depend.setAll (deep3);
OpenJPAEntityManager em = (OpenJPAEntityManager)currentEntityManager();
startTx(em);
em.persistAll (ent, depend);
endTx(em);
long id = ent.getId ();
long rel1Id = rel1.getId ();
long rel2Id = rel2.getId ();
long deep1Id = deep1.getId ();
long deep2Id = deep2.getId ();
long deep3Id = deep3.getId ();
long dependId = depend.getId ();
endEm(em);
em = (OpenJPAEntityManager)currentEntityManager();
ent = em.find (CascadesEntity.class, id);
rel1 = ent.getAll ();
assertEquals (rel1Id, rel1.getId ());
deep1 = rel1.getAll ();
assertEquals (deep1Id, deep1.getId ());
assertEquals (1, ent.getAllCollection ().size ());
rel2 = ent.getAllCollection ().iterator ().next ();
assertEquals (rel2Id, rel2.getId ());
assertEquals (1, rel2.getAllCollection ().size ());
deep2 = rel2.getAllCollection ().iterator ().next ();
assertEquals (deep2Id, deep2.getId ());
depend = ent.getDependent ();
assertEquals (dependId, depend.getId ());
deep3 = depend.getAll ();
assertEquals (deep3Id, deep3.getId ());
startTx(em);
em.remove (ent);
assertTrue (em.isRemoved (ent));
assertTrue (em.isRemoved (rel1));