The following code is the User class . Along with the attributes declaration, you use the Bean Validation1 and Hibernate Validator2 annotations. A valid new user must have the following:
username: This must not be empty and must have between 5 and 15 characters. This field is the user database table’s primary key.
password: This must not be empty and must have a minimum of five characters.
name: This must not be empty.
email: This must not be empty and must be a valid e-mail address.
@Entity
@Table(name = "user")
public class User {
@Id
@NotEmpty
@Size(min = 5, max = 15)