@Retention(value=RUNTIME) @Target(value=METHOD) public @interface DbEnumValue
This is the preferred option for mapping Enum's to DB values (preferred over the JPA standard @Enumerated and Ebean's @EnumValue annotations).
public enum Status {
NEW("N"),
ACTIVE("A"),
INACTIVE("I");
String dbValue;
Status(String dbValue) {
this.dbValue = dbValue;
}
@DbEnumValue
public String getValue() {
return dbValue;
}
}
| Modifier and Type | Optional Element and Description |
|---|---|
int |
length
The column length for VARCHAR.
|
DbEnumType |
storage
Specify the database type used to store the values (VARCHAR or INTEGER).
|
public abstract DbEnumType storage
public abstract int length
When 0 the length is determined automatically based on the maximum length of the values used.
Specify this to allow for future string enum values that might be larger then the automatically determined maximum length.
Copyright © 2019. All rights reserved.