// delete from intermediary table only when collection NOT removal aware
public void testDelete_NonRemovalAware()
{
ClassDescriptor cld = broker.getClassDescriptor(Paper.class);
CollectionDescriptor cod = cld.getCollectionDescriptorByName("qualifiers");
Class collectionClass = cod.getCollectionClass();
cod.setCollectionClass(ManageableArrayList.class);
try
{
Paper paper = createPaper();
Identity paperId = new Identity(paper, broker);
List qualifiers = paper.getQualifiers();
Qualifier qual1 = (Qualifier) qualifiers.get(0);
Qualifier qual2 = (Qualifier) qualifiers.get(1);
// remove first object
qualifiers.remove(0);
broker.beginTransaction();
broker.store(paper);
broker.commitTransaction();
broker.clearCache();
broker.beginTransaction();
Paper retPaper = (Paper) broker.getObjectByIdentity(paperId);
assertEquals(1, retPaper.getQualifiers().size());
// target object qual1 should NOT be deleted
Qualifier retQual1 = (Qualifier) broker.getObjectByIdentity(new Identity(qual1, broker));
Qualifier retQual2 = (Qualifier) broker.getObjectByIdentity(new Identity(qual2, broker));
assertNotNull(retQual1);
assertNotNull(retQual2);
broker.commitTransaction();
}
finally
{
cod.setCollectionClass(collectionClass);
}
}