Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
quaff wants to merge 1 commit into mybatis:master
base: master
Choose a base branch
Loading
from quaff:patch-1

Conversation

@quaff
Copy link
Contributor

@quaff quaff commented Feb 24, 2025

No description provided.

MasatoshiTada reacted with thumbs up emoji
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
Copy link
Member

harawata commented Feb 27, 2025
edited
Loading

Hello @quaff ,

Thank you for the PR, but I don't think this is a good idea.

  1. Users can easily create Stream in their own code after retrieving List or Cursor from MyBatis.
  2. (削除) Users should be able to close Cursor at any point, but it's not possible if we return Stream wrapping Cursor. (削除ここまで)

I will close this as "won't fix".

Copy link
Contributor Author

quaff commented Feb 27, 2025
edited
Loading

Users can easily create Stream in their own code after retrieving List or Cursor from 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

Copy link
Member

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).

Copy link
Contributor Author

quaff commented Feb 27, 2025

I'll reopen for other devs to comment.

Thanks for reconsideration. @harawata

It's not obvious, however, that the returned Stream wraps Cursor which 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.

Copy link
Member

harawata commented Feb 27, 2025
edited
Loading

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).

Copy link

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.

hondaya14, GeorgeSalu, and ko-sasaki reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /