How can i map enums as string to database in Map in Hibernate I now how to map key with @MapKeyEnumerated, but how to do the same with value of my map ?
Part of Model code :
@MapKeyClass(value = Allergen.class)
@MapKeyEnumerated(value = EnumType.STRING)
@ElementCollection(targetClass = AllergicStatus.class)
private Map<Allergen,AllergicStatus> allergens;
Where Allergen and AllergicStatus is enum
Answer for my own question is @Enumerated(EnumType.STRING)
@MapKeyClass(value = Allergen.class)
@MapKeyEnumerated(value = EnumType.STRING)
@ElementCollection(targetClass = AllergicStatus.class)
@Enumerated(value = EnumType.STRING)
private Map<Allergen,AllergicStatus> allergens;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With