Hibernate: “no type name” with “AttributeConverter” on Map

…衆ロ難τιáo~ 提交于 2019-12-11 08:54:45

问题


I have this:

@Column
@Convert(converter = MyMapConverter.class)
private Map<String, String> temp;

MyMapConverter is a simple JPA-AttributeConverter:

@Converter
public class MyMapConverter implements AttributeConverter<HashMap<String, String>, String> {

    @Override
    public String convertToDatabaseColumn(HashMap<String, String> attribute) {
        return attribute.toString();
    }

    @Override
    public HashMap<String, String> convertToEntityAttribute(String dbData) {
        return ...
    }

}

When starting the application, actual hibernate version complains with this error:

Caused by: org.hibernate.MappingException: No type name
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:407)
    at org.hibernate.tuple.PropertyFactory.buildStandardProperty(PropertyFactory.java:267)
    at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:54)
    at org.hibernate.mapping.Component.getType(Component.java:169)
    at org.hibernate.mapping.Property.getType(Property.java:68)

What is wrong?

来源:https://stackoverflow.com/questions/48188365/hibernate-no-type-name-with-attributeconverter-on-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!