Chapter 2. Using the Validator framework
Hibernate Validator is intended to be used to implement multi-layered data validation, where constraints are expressed in a single place (the annotated domain model) and checked in various different layers of the application.
This chapter will cover Hibernate Validator usage for different layers
2.1. Database schema-level validation
Out of the box, Hibernate Annotations will translate the constraints you have defined for your entities into mapping metadata. For example, if a property of your entity is annotated
@NotNull
, its columns will be declared as not null
in the DDL schema generated by Hibernate.
Using hbm2ddl, domain model constraints will be expressed into the database schema.
If, for some reason, the feature needs to be disabled, set
hibernate.validator.apply_to_ddl
to false
.