I have an object that contains an enum property. This property can be any of my Enums types in my code base:
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 the exception: โInvalid data type: for input string:โ [B @ f0569a. โI changed FooBar to save the property as an integer that works, but thatโs not what I need. I need an actual listing Any suggestions on how to make this work so that Enum can be saved as an int, but later pulled into the correct Enum type?
java enums hibernate jpa
codecraig
source share