Using ENUM in Hibernate
1. create enum type
public enum LoginStatus {
ACTIVE,
INACTIVE
}
2. add property with Enum type
private LoginStatus status;
public LoginStatus getStatus() {
return status;
}
public void setStatus(LoginStatus status) {
this.status = status;
}
3. if we use the above code this will insert the entries as index of ENUM values (0,1) in DB insteade of ACTIVE,INACTIVE values
if we want to insert as values then we need to create new table with ENUM values.
1. create enum type
public enum LoginStatus {
ACTIVE,
INACTIVE
}
2. add property with Enum type
private LoginStatus status;
public LoginStatus getStatus() {
return status;
}
public void setStatus(LoginStatus status) {
this.status = status;
}
3. if we use the above code this will insert the entries as index of ENUM values (0,1) in DB insteade of ACTIVE,INACTIVE values
if we want to insert as values then we need to create new table with ENUM values.
No comments:
Post a Comment