Reputation: 858
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
Upvotes: 5
Views: 1384
Reputation: 858
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;
Upvotes: 6