[英]Hibernate how to map Enum key and value in Map<enum,enum> as a String
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 ? 我如何在Hibernate的Map中将枚举作为字符串映射到数据库中,现在如何使用@MapKeyEnumerated映射键,但是如何对我的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) 我自己的问题的答案是@Enumerated(EnumType.STRING)
@MapKeyClass(value = Allergen.class)
@MapKeyEnumerated(value = EnumType.STRING)
@ElementCollection(targetClass = AllergicStatus.class)
@Enumerated(value = EnumType.STRING)
private Map<Allergen,AllergicStatus> allergens;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.