Ya, tetapi Anda harus menggunakan API khusus Postgres. Pada kode di atas Anda perlu mengganti metode from/to dengan yang berikut:
@Override
public ObjectNode from(Object databaseObject) {
if (databaseObject == null) { return null; }
try {
PGobject dbo = (PGobject) databaseObject;
return mapper.readValue(dbo.getValue(), ObjectNode.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public Object to(ObjectNode userObject) {
if (userObject == null) { return null; }
try {
PGobject dbo = new PGobject();
dbo.setType("json");
dbo.setValue(mapper.writeValueAsString(userObject));
return dbo;
} catch (JsonProcessingException|SQLException e) {
throw new RuntimeException(e);
}
}