Hibernate:Map上的“没有类型名称”和“AttributeConverter”

时间:2018-01-10 13:17:24

标签: hibernate jpa-2.0

我有这个:

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

MyMapConverter是一个简单的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 ...
    }

}

启动应用程序时,实际的hibernate版本会抱怨此错误:

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)

有什么问题?

0 个答案:

没有答案