-
Notifications
You must be signed in to change notification settings - Fork 13k
Support Stream as mapper method return type #3419
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
Conversation
aa67be6 to
5d63232
Compare
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
5d63232 to
cb0f0a6
Compare
Hello @quaff ,
Thank you for the PR, but I don't think this is a good idea.
- Users can easily create
Streamin their own code after retrievingListorCursorfrom MyBatis. (削除) Users should be able to closeCursorat any point, but it's not possible if we returnStreamwrappingCursor. (削除ここまで)
I will close this as "won't fix".
Users can easily create
Streamin their own code after retrievingListorCursorfrom MyBatis.
Users would expect returning standard Stream instead of proprietary Cursor from declarative mapper interface, especially for beginner, they may don't even know Cursor, see GH-3213.
It's not so easily to create Stream from Cursor, Sure it's easily for List, but List is not suitable for large result, It may cause OOM issue.
It's more easily to create Optional in their own code, but MyBatis provide built-in supports, so I think Stream supports is reasonable, WDYT @harawata
Thanks for the comment, @quaff !
I'll reopen for other devs to comment.
Comparison with Optional is a fair point.
It's not obvious, however, that the returned Stream wraps Cursor which requires extra care (i.e. resultOrdered="true"), so I still prefer not to merge this personally.
And, in case other devs like this, I would request some additional documentation (please do not work on it yet. I don't want you to waste any time).
I'll reopen for other devs to comment.
Thanks for reconsideration. @harawata
It's not obvious, however, that the returned
StreamwrapsCursorwhich requires extra care (i.e.resultOrdered="true").
I researched #2812 (comment), I don't think extra care required for resultOrdered="true", Stream inherit all features and limitations from Cursor, It doesn't introduce new things, correct me if I'm wrong.
What I meant was it is not clear to users that "Stream inherits all features and limitations from Cursor" and it requires additional documentation IF we merge this (again, please do not work on the doc update yet).
MasatoshiTada
commented
Jul 10, 2025
Is there any progress on this PR? 👀
Stream is very useful for users as it allows for separation of concerns.
Since Cursor is a MyBatis-specific class, our code becomes dependent on MyBatis.
By using Stream, the dependency of our code on MyBatis is reduced.
No description provided.