* Tests that deleting a source of a flattened relationship with CASCADE rule results
* in deleting a join and a target.
*/
public void testCascadeToManyFlattened() {
// testing Artist.groupArray relationship
ArtGroup aGroup = context.newObject(ArtGroup.class);
aGroup.setName("Group Name");
Artist anArtist = context.newObject(Artist.class);
anArtist.setArtistName("A Name");
anArtist.addToGroupArray(aGroup);
assertTrue(anArtist.getGroupArray().contains(aGroup));
context.commitChanges();
SQLTemplate checkQuery = new SQLTemplate(
Artist.class,
"SELECT * FROM ARTIST_GROUP");
checkQuery.setFetchingDataRows(true);
List<?> joins1 = context.performQuery(checkQuery);
assertEquals(1, joins1.size());
context.deleteObjects(anArtist);
assertEquals(PersistenceState.DELETED, aGroup.getPersistenceState());
assertFalse(anArtist.getGroupArray().contains(aGroup));
context.commitChanges();
List<?> joins2 = context.performQuery(checkQuery);
assertEquals(0, joins2.size());