Adding JSR 303 constraints to persistent fields
JSR 303 (bean validation) defines a standard approach for annotations-based JavaBeans validation. In this recipe we'll look at how Spring Roo's field
command can be used to add JSR 303 validation constraints to persistent fields of entities.
The following table shows the validation constraints that apply to fields defined in the Flight
entity and FlightKey
class of our flight-app
project:
Persistent field |
Constraint |
JSR 303 annotation |
---|---|---|
|
Not null |
|
|
Not null |
|
|
Not null Maximum seats 200 Minimum seats 100 |
|
|
Not null Maximum length of value of |
|
|
Not null Maximum length of value of |
|
|