I use spring-jpa with hibernate implementation and postgresql. I try to save an column who is a hstore
@Column(columnDefinition = "hstore")
@Convert(converter = MapToStringConveter.class)
private Map<String, String> fields = new HashMap<>();
I have a converter
@Converter
public class MapToStringConveter implements AttributeConverter<Map<String, String>, String>, Serializable {
@Override
public String convertToDatabaseColumn(Map<String, String> attribute) {
return HStoreConverter.toString(attribute);
}
@Override
public Map<String, String> convertToEntityAttribute(String dbData) {
if (dbData != null) {
return HStoreConverter.fromString(dbData);
}
return null;
}
}
update
public.enumerations
set
created_at=?,
updated_at=?,
enum_type_id=?,
fields=?
where
id=?
when you do the prepare statement, i don't know if you do ps.setObject(1, map, Types.OTHER, -1); ... but i read that don't work... ps.setObject(1, map); should work |