Using a Collection Validator
You can use collection validation to:
1. Compute the average, count, sum, min, or max of an attribute in a child of the current entity object
2. Compare the computed value with a literal, a view object attribute, an entity attribute, or the value returned by a SQL query, a view accessor, or an expression
For example, you could verify that the total value of an order (the sum of its line items) does not exceed $10,000, as depicted in the example in the slide.
When you use a Collection validator, a <CollectionValidationBean> tag is added to the XML file.
You set the following options to define a Collection validator:
Operation: Select sum, average, count, min, or max.
Accessor: Select an association that has been defined for the entity.
Attribute: Select the child attribute on which the operation is to be performed.
Operator: Select equals, not equals, less than, greater than, less than or equal to, or greater than or equal to.
Compare with: Select literal value, query result, view object attribute, view accessor attribute, expression, or entity attribute.
Compare with value: Select or define the value with which to compare the calculation.