With JPA I try to map a object of a @Entity class a postgres DB json column.
@Enity
public class MyEntity{
@NotNull
@ToString.Exclude
@Convert(converter = JsonSerializationConverter.class)
private Object value;
}
public class JsonSerializationConverter implements AttributeConverter<Object, String> {
private static final ObjectMapper mapper = new ObjectMapper();
@SneakyThrows
@Override
public String convertToDatabaseColumn(final Object attribute) {
return mapper.writeValueAsString(attribute);
}
When running locally it works works like a charm, but for unknown reason it fails running in azure cloud on k8n pod:
SchemaManagementException: Schema-validation: wrong column type encountered in column [value] in table [preference] found [json (Types#OTHER)], but expecting [varchar(255)
Mainly other stackoverflow issue refer this: postgre bug and suggest to set data-source-properties: stringtype=unspecified
This unfortunately does not fix the problem in azure kn8 ubuntu pod. I tried all like:
spring.datasource.url: jdbc:postgresql://xyz:5432/dbname?stringtype=unspecified
spring.datasource.hikari.data-source-properties.stringtype: unspecified