I'm using Spring data r2dbc repositories to save pojo's to Postgres DB. I have a class with complex field definition
:
// Getters and setters omitted for brevity
public class TestType {
@Id
private Long id;
private TestDefinition definition;
public static class TestDefinition {
private String testField;
}
}
I'm trying to find a way to add a converter which will serialize this complex field to JSON when ReactiveCrudRepository.save
method is called. I looked at source code and read the API docs but am unable to find a place where my logic could be plugged in.
This was easy to do in projects using JPA
and Hibernate
by creating custom UserType
classes. If anybody has any pointers I'd be much obliged for any assistance.
Edit
This is now doable, check out: https://medium.com/@nikola.babic1/mapping-to-json-fields-with-spring-data-r2dbc-and-reactive-postgres-driver-1db765067dc5
Spring Data R2DBC is still young and its feature set grows with every day. Right now, there's no support for custom conversions but you might want to file a ticket.
PS: Hibernate is around since 2001 (more or less), Spring Data R2DBC was started this year in May.