Hibernate 无法使用JPA批注映射hashmap

Hibernate 无法使用JPA批注映射hashmap,hibernate,jpa,hashmap,Hibernate,Jpa,Hashmap,我正在使用dropwizard,它在内部使用JPA注释和hibernate来映射对象。其中一个对象有一个映射字段,我将其定义为 @Column @ElementCollection(targetClass=String.class) Map<String, String> routes; 我已经试过了很多在网上提到的东西 添加了@MapKey注释 在getter上添加了注释 将Map更改为HashMap似乎没有任何东西可以修复它。您可以使用@MapKeyCo

我正在使用dropwizard,它在内部使用JPA注释和hibernate来映射对象。其中一个对象有一个映射字段,我将其定义为

    @Column
    @ElementCollection(targetClass=String.class)
    Map<String, String> routes;
我已经试过了很多在网上提到的东西

添加了@
MapKey
注释 在getter上添加了注释
将Map更改为HashMap似乎没有任何东西可以修复它。

您可以使用@MapKeyColumn(name=“column\u name”)。此链接可能很有用:

您想将此地图保存到哪里?进入专栏?加入(加入)表格?进入一个连载的专栏?“targetClass”想要做什么?您在字段上定义了泛型,因此targetClass与序列化表的列无关。在这种情况下,您可以尝试
@Lob
,或者在该链接上使用类似的
@AttributeConverter
,在添加@MapKeyColumn注释后得到相同的结果。您是否尝试了下面的代码,并使用Map routes=new HashMap();也可以使用@MapKeyColumn。检查这个类似的问题:这个:
org.hibernate.MappingException: Could not determine type for: java.util.Map, at table