-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
DefaultRecordMapper cannot fill nested objects properties via constructors #9000
Comments
Thank you for your report. We will look into this and try to address it as part of the upcoming 3.12 release. |
Thanks! |
I looked into the code and the Further I noticed that in your MCVE you are using the |
@knutwannheden Oops true, first test should be Using a builder is a workaround to getting 1 nesting level, but not more. |
I think that we may have initially misunderstood your request on Twitter. According to the documentation of For Given the complexity of this issue, I am doubtful whether we will be able to fit it into the 3.12 release anymore. I think we might however be able to change the |
I see, thank you for the suggestion. Is there some sample code on how to implement the special record mapper that would use the I already use some mappers for UDTs implementing |
I will still have to test it myself to make sure it actually works, but I was thinking a |
AFAICT this is really a duplicate of #6598 I will leave this issue open for now, however, so that we can verify the implementation against your excellent MCVE. Thanks again for the effort! |
@eduramiba I have now committed a change to jOOQ 3.12 so that the The code to set up the final Configuration configuration = create.configuration();
configuration.set(new RecordMapperProvider() {
@SuppressWarnings("unchecked")
@Override
public <R extends Record, E> RecordMapper<R, E> provide(RecordType<R> recordType, Class<? extends E> type) {
if (type == A.class)
return record -> (E) new DefaultRecordMapper<>(recordType, A.Builder.class, configuration).map(record).build();
if (type == B.class)
return record -> (E) new DefaultRecordMapper<>(recordType, B.Builder.class, configuration).map(record).build();
else
return new DefaultRecordMapper<>(recordType, type, configuration);
}
}); |
@knutwannheden Awesome, thank you! I will probably do that until #6598 is ready :) |
Expected behavior and actual behavior:
DefaultRecordMapper
should be able to fill nested objects properties with methods such asfetchOneInto(X.class)
using class and nested classes constructors properly annotated with@ConstructorProperties
.It will probably work using setters but I want all my models to be immutable and directly mapped by JooQ.
Steps to reproduce the problem
See MCVE here: https://github.com/eduramiba/jooq-issue-recordmapper
Following conversation at https://twitter.com/eduramiba/status/1149303730333986817
Versions:
These I don't think they matter:
Thank you!
The text was updated successfully, but these errors were encountered: