I have an entity that contains an enum property. That property can be any one of my types of Enums in my codebase:
public enum AutomobileType {
CAR, TRUCK, MOTORCYCLE
}
public enum BoatType {
ROW_BOAT,YACHT,SHIP
}
@Entity
public class FooBar {
@Enumerated(value=EnumType.ORDINAL)
private Enum enumValue;
public void setEnumValue(Enum value) { ... }
public Enum getEnumValue() { ... }
}
This fails with an exception, "Wrong data type: For input string: "[B@f0569a". I changed FooBar to store the property as an Integer which works, but that's not what I need. I need the actual enum. Any suggestions on how to make this work so that the Enum can be persisted as int but later pulled out into the correct Enum type?