assertEquals(first, second.joins().get(0).firstEntity());
}
public void test23_insertFlattenedManyToManyRelationship() {
FirstEntity first = ERXEOControlUtilities.createAndInsertObject(ec, FirstEntity.class);
SecondEntity second = ERXEOControlUtilities.createAndInsertObject(ec, SecondEntity.class);
first.addToJoins_secondEntityRelationship(second);
ec.saveChanges();
ec.invalidateAllObjects();
NSArray<SecondEntity> results2 = fetchAll(SecondEntity.ENTITY_NAME);
assertEquals("Expecting only one row", 1, results2.count());
second = results2.get(0);
assertEquals(1, second.joins_firstEntity().count());
assertEquals(first, second.joins_firstEntity().get(0));
NSArray<FirstEntity> results = fetchAll(FirstEntity.ENTITY_NAME);
assertEquals("Expecting only one row", 1, results.count());
first = results.get(0);
assertEquals(1, first.joins_secondEntity().count());
assertEquals(second, first.joins_secondEntity().get(0));
}