Niclas, > That raises an interesting question... > > Shouldn't a removed entity's reference in any of the optional association > references be silently removed?? A kind of lazy GC?
Interesting question indeed. Sounds a bit like magic, or Migration. So, this would mean 'nulling' such Associations and 'trimming' such Many|NamedAssociations transparently. But, this can't be done on 'load' like Migration as this would cause too much eager loading of all @Optional Associations and all Many|NamedAssociations. So it should be done on 'access', lazily as you said. Moreover, on one hand an application developper should care about manually maintaining relationships ; on the other hand, this feature would allow her to let the Zest runtime transparently handle some of the relationships, based on relationships 'optionality'. I have no strong opinion about it but it feels like magic and I think it goes against least surprise principle. Or, if we could apply concerns on methods, then this could be an opt-in Concern for Associations. Pseudo-code: @Optional @AutoGCedAssociation<Gizmo> gizmo(); @AutoGCedManyAssociation<Gizmo> gizmos(); @AutoGCedNamedAssociation<Gizmo> gizmoz(); 'AutoGCed' being an awful name. /Paul
