-
Notifications
You must be signed in to change notification settings - Fork 356
Storing non root entities in serialized form [DATAJDBC-450] #673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Mihhail Verhovtsov commented I had a similar use-case where I wanted to support Postgres's JSONB columns. I didn't want to use a wrapper for my collections as its makes data access more cumbersome. Additionaly, I am not convinced that type-based converters are a good option either in terms of flexibility (BTW, do they properly support generics?). I wanted to achieve something like this: @Data
public class Company {
private @Id Long id;
private String name;
@JSONB
private List<Representative> representatives = new ArrayList<>();
} This gives me the freedom to customize serialization mechanism of particular properties. I envisioned that The first problem was that Spring Data JDBC treated collections and maps as entity collections. I extended This way I got into Naturally, I tried going up one level and override that behaviour of What are your thoughts on this? Maybe I am not seeing a simpler way already supported by Spring Data JDBC? I would love to devote my time supporting this use case |
Jens Schauder commented I think there are a couple of different things that we should try to keep separate. 1. adding conversions for properties (not based on the type of the property). We probably want to build on some yet to be created infrastructure in Commons. See DATACMNS-1036 2. We might need more than just the conversion itself, but also a way to generate SQL snippets for writing and reading. For example MySql seems to need a If anyone wants to tackle this they should probably start with a simple implementation for this issue, together with creating the necessary infrastructure for DATACMNS-1036
|
This would be really great addition to Spring Data JDBC. It would be then a perfect fit for DDD. Clean aggregates that are stored in single RDBMS row within tables that can be indexed by root aggregate attributes, but also to some degree on child entity attributes (depending on a RDBMS) |
Since DATACMNS-1036 is delivered, could this be prioritized? |
Bahadır Yağan opened DATAJDBC-450 and commented
It may be a good feature to optionally store non-root entities in a single column in the aggregate root's table, rather than separate table(s)
Object tree will be serialized (possibly as json) and stored in a single text column. The user than has the option of using their DBMS' support for such columns. (jsonb or hstore for postgres is an example)
My somewhat related SO question:
https://stackoverflow.com/questions/58910098/mapstring-string-single-column-mapping-in-spring-data-jdbc
Issue Links:
DATAJDBC-476 BasicRelationalConverter.writeValue(…) assumes eager entity conversion
DATACMNS-1036 Add API for property specific converters
The text was updated successfully, but these errors were encountered: