// delete from intermediary table only when collection NOT removal aware
public void testDelete_NonRemovalAware() throws Exception
{
ClassDescriptor cld = _conn.getDescriptorFor(Paper.class);
CollectionDescriptor cod = cld.getCollectionDescriptorByName("qualifiers");
Class collectionClass = cod.getCollectionClass();
cod.setCollectionClass(ManageableArrayList.class);
try
{
Paper paper = createPaper();
Identity paperId = _conn.getIdentity(paper);
List qualifiers = paper.getQualifiers();
Qualifier qual1 = (Qualifier) qualifiers.get(0);
Qualifier qual2 = (Qualifier) qualifiers.get(1);
// remove first object
qualifiers.remove(0);
Transaction trans = _kit.getTransaction(_conn);
trans.begin();
_conn.makePersistent(paper);
trans.commit();
;
//broker.clearCache();
trans = _kit.getTransaction(_conn);
trans.begin();
Paper retPaper = (Paper) _conn.getObjectByIdentity(paperId);
assertEquals(1, retPaper.getQualifiers().size());
// target object qual1 should NOT be deleted
Qualifier retQual1 = (Qualifier) _conn.getObjectByIdentity(_conn.getIdentity(qual1));
Qualifier retQual2 = (Qualifier) _conn.getObjectByIdentity(_conn.getIdentity(qual2));
assertNotNull(retQual1);
assertNotNull(retQual2);
trans.commit();
;
}
finally
{
cod.setCollectionClass(collectionClass);
}
}