assertEquals("xSUB1_SUB1", sub1Sub1.getSub1Sub1Name());
}
public void testDelete_Mix() throws Exception {
TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
TableHelper ivSub1Table = new TableHelper(dbHelper, "IV_SUB1");
ivSub1Table.setColumns("ID", "SUB1_NAME");
TableHelper ivSub2Table = new TableHelper(dbHelper, "IV_SUB2");
ivSub2Table.setColumns("ID", "SUB2_NAME");
TableHelper ivSub1Sub1Table = new TableHelper(dbHelper, "IV_SUB1_SUB1");
ivSub1Sub1Table.setColumns("ID", "SUB1_SUB1_NAME");
// insert
ivRootTable.insert(1, "xROOT", null);
ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
ivSub1Table.insert(2, "xSUB1");
ivRootTable.insert(3, "xSUB1_SUB1_ROOT", "IvSub1Sub1");
ivSub1Table.insert(3, "xSUB1_SUB1_SUBROOT");
ivSub1Sub1Table.insert(3, "xSUB1_SUB1");
ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
ivSub2Table.insert(4, "xSUB2");
SelectQuery query = new SelectQuery(IvRoot.class);
List<IvRoot> results = context.performQuery(query);
assertEquals(4, results.size());
Map<String, IvRoot> resultTypes = new HashMap<String, IvRoot>();
for (IvRoot result : results) {
resultTypes.put(result.getClass().getName(), result);
}
assertEquals(4, resultTypes.size());
IvRoot root = resultTypes.get(IvRoot.class.getName());
context.deleteObject(root);
IvSub1 sub1 = (IvSub1) resultTypes.get(IvSub1.class.getName());
context.deleteObject(sub1);
context.commitChanges();
assertEquals(2, ivRootTable.getRowCount());
assertEquals(1, ivSub1Table.getRowCount());
assertEquals(1, ivSub1Sub1Table.getRowCount());
assertEquals(1, ivSub2Table.getRowCount());
results = context.performQuery(query);
assertEquals(2, results.size());
}