After paying a lot with ERXKey, I came to the conclusion that the current templates are correct. Using the collection as the type seems good at first but if you use aggregation functions they no longer works.
ERXKey have 2 typed methods to get the value:
public T valueInObject(Object obj)
public NSArray<T> arrayValueInObject(Object obj)
When you know the value is an array, use the arrayValueInObject variant. It always works even when traversing toMany relationships to get all the firstName of contacts of some entity like this:
NSArray<String> firstNames = SomeEntity.CONTACTS.dot(Contact.FIRST_NAME).arrayValueInObject(anInstanceOfSomeEntity);
If you want the latest birthDate:
LocalDate lastBirthDate = SomeEntity.CONTACTS.atMax(Contact.BIRTH_DATE).valueInObject(anInstanceOfSomeEntity);
There is many operations available and it is probably not possible to determine the final type of an ERXKey chain (array or instance) and using the 2 value getters always works.
For relationships, I do not think it can really create confusion but if your key represent an array of String or number values, you will probably use aggregate key one day that will no longer works as expected because your ERXKey have a NSArray type.