Since NamedAssociations are being discussed in ZEST-23, I thought it would be appropriate to remind people what Associations are and how they work.
We have Association, ManyAssociation and NamedAssociation. Associations are references to Entities. These references are by Identity and handled automatically under the hood in the Qi4j runtime. Association = A single reference. ManyAssociation = A collection of Associations. NamedAssociation = Strings mapped to Assocations. ValueComposites can also contain Associations. So even though ValueComposites are Immutable by definition, it is said that the Association is Immutable, albeit the referenced Entity is not, because the Association should be seen as only the Reference value. ValueComposites can not use the Associations unless there is a "Current Unit Of Work" available in the thread, in which case the Entity will be retrieved upon the get() methods of Associations. Associations can have meta information on them, and they can be "aggregated". Metainformation is a general Qi4j mechanism to provide class level information to the code. Properties, Modules and many other things can be given meta information, which is available to code to use. Annotations are automatically added as meta information. @Aggregated is an annotation that is explicitly handled in the UnitOfWork, which indicates that if the holding entity is removed, then the referenced entity/entities should also be removed. Currently, the referenced entity is not removed when the reference is cleared. And the aggregation model should be re-visited in due time, to better support the Aggregate concept in DDD. Hope that helps. Cheers -- Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java
