You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
returnInstanceForEmptyRow does not work for constructor auto-mapping #2665
I could verify a problem (i.e. returnInstanceForEmptyRow is not correctly applied when MyBatis performs constructor-automapping), so I am going to fix it.
The attached test, however, kind of misses the point and I would like to clarify that.
As seen in the log, the query in the test does not return any row.
... PersonMapper.getById - ==> Preparing: select name from person where id=?
... PersonMapper.getById - ==> Parameters: -1(Long)
... PersonMapper.getById - <== Total: 0
When there is no row in the result set, MyBatis returns null even if returnInstanceForEmptyRow is enabled.
"empty row" means that there is a row in the result set and all mapped columns are NULL.
The option returnInstanceForEmptyRow was added to differentiate these two cases.
changed the title [-]`returnInstanceForEmptyRow` does not seem to work (at least in this case)[/-][+]`returnInstanceForEmptyRow` does not work for constructor auto-mapping[/+]on Aug 27, 2022
Activity
harawata commentedon Aug 26, 2022
Hello @cvmocanu ,
Thanks for the report & repro!
I could verify a problem (i.e.
returnInstanceForEmptyRowis not correctly applied when MyBatis performs constructor-automapping), so I am going to fix it.The attached test, however, kind of misses the point and I would like to clarify that.
As seen in the log, the query in the test does not return any row.
When there is no row in the result set, MyBatis returns
nulleven ifreturnInstanceForEmptyRowis enabled."empty row" means that there is a row in the result set and all mapped columns are NULL.
The option
returnInstanceForEmptyRowwas added to differentiate these two cases.[-]`returnInstanceForEmptyRow` does not seem to work (at least in this case)[/-][+]`returnInstanceForEmptyRow` does not work for constructor auto-mapping[/+]returnInstanceForEmptyRow should work for constructor auto-mapping
harawata commentedon Aug 27, 2022
@cvmocanu ,
I have committed the fix.
As I explained, the test you attached still fails.
Please let me know if you have any question.
Thanks again for your contribution!
cvmocanu commentedon Aug 29, 2022
@harawata, thanks so much.
I've fixed the example, in case it helps:
mybatis-bug-good-example.zip
Do you have an idea when the fix will be released?
returnInstanceForEmptyRow should work for constructor auto-mapping
returnInstanceForEmptyRow should work for constructor auto-mapping