Enumeration properties with the @Enumerated(EnumType.STRING) on the getter will still be treated as ordinal and throw SQL exceptions when loading if there are any fields with annotations in the same entity.
This can be worked around by not mixing field and getter annotations.
Example:
create table MyEntity (
id integer auto_increment,
value enum('A', 'B')
);
enum MyEnum { A, B };
@Entity
class MyEntity {
@Id private int id;
private MyEnum value;
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
@Enumerated(EnumType.STRING)
public MyEnum getValue() {
return this.value;
}
public void setValue(MyEnum value) {
this.value = value;
}
}
|