The Bean Validation API (JSR0303) can be hooked up with JPA so that you have validation of an objects values prior to persistence, update and deletion. To do this
To give a simple example of what you can do with the Bean Validation API
@Entity
public class Person
{
@Id
@NotNull
private Long id;
@NotNull
@Size(min = 3, max = 80)
private String name;
...
}So we are validating that instances of the Person class will have an "id" that is not null and that the "name" field is not null and between 3 and 80 characters. If it doesn't validate then at persist/update an exception will be thrown.