Java Reference
In-Depth Information
// Send the order to the database
return order;
Now let's consider a class that extends another class, overriding method(s) that contain the
@ValidateOnExecution annotation. It is possible to override the validation type, or specify another validation type
within the extending class. In the following example, WidgetOrderingService extends the CatalogService class
that was previously presented. The @ValidateOnExecution annotation has been specified at the class level,
indicating that any GETTER_METHODS or CONSTRUCTORS should be validated.
public class WidgetOrderingService extends CatalogService {
public WidgetOrderingService(){
public Order placeOrder(
@NotNull @Size(min = 3, max = 20) String customerNumber,
@NotNull @Valid Widget widget,
@Min(1) int quantity) {
Order order = new Order();
// Do something specific with widget order
return order;
Another way to achieve customizable validation is to utilize either the executable-validation or
default-validated-executable-types elements within the validation.xml configuration file. If the
executable-validation element is specified, and its enabled attribute is set to false , then executable validation
is disabled. However, if the default-validated-executable-types element is specified as a sub-element to the
executable-validation element, then specific executable types can be specified for executable validation.
For example, the following excerpt from a validation.xml file demonstrates how to disable executable validation
for all executables with the exception of getter methods:
Search WWH ::

Custom Search