I don't know if you can do that in the model (the @sum) or not. Also, flattened attributes can have inconsistency problems. I'd lean towards the Java solution.
Flor