A Sum is defined by a method with the @Sum annotation:
The name of the method has a special meaning if (and only if) the
For instance, a Sum for the attribute
The value of the attribute will be updated to reflect the sum of the specified attribute in the child objects whenever necessary. This includes objects being added to and removed from the parent object, as well as modifications to the children objects that change their qualification in the Sum.
A Sum is not recalculated from scratch, but rather adjusted as necessary. For instance, when a new (qualifiying) child is added to the parent, the Sum attribute will be incremented by the child's amount. This means that there is very little performance impact.
If the method contains code, that code will be invoked every time the sum is adjusted, but this is meant only as a debugging aid: the code should not do anything that affects the object.