Look the example and see how mapping with hibernate annotation a enum type column.
Example :
/** User.java**/
@Entity
@Table(name = "usuario")
public class User {
@Enumerated(EnumType.STRING)
@Column(name = "perfil", length = 32)
@NotNull(message = "You need choose a perfil for this user")
private Perfil perfil;
}
/** Perfil Enum Class **/
public enum Perfil {
ADMIN("Admin"),
CLIENT("Client"),
SALESMAN("Salesman");
private final String label;
private Perfil(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
}
Like this:
Like Loading...
Related