I'm currently using Hibernate with MySql. I'm trying to map an enum type, which according to several examples seems really straight forward.
However, the column that is generated contains a VARCHAR(255) rather than an enum type like it expected.
Here's the simple enum class.
public enum Gender {
MALE,
FEMALE
}
Here's the annotation
@Enumerated(EnumType.STRING)
@Column(name = "gender")
public Gender getGender() {
return gender;
}
And here's the field that's generated from this
| gender | varchar(255) | NO | | NULL | |
I can't see why the type is a String rather than an enum. I've tried changing the Enum type to Ordinal, but then I just get an Integer rather than a string, still no enum.
Any help would be appreciated.
1 Answer 1
I don't think it's possible because ENUM is not a standard SQL datatype. By default @Enumerated is mapped to integer, if EnumType.STRING is used then column is mapped to a string.