Skip to content
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

Change Iterable<T> to List<T> return types for Repository and Template API methods #1623

Closed
mp911de opened this issue Sep 26, 2023 · 5 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@mp911de
Copy link
Member

mp911de commented Sep 26, 2023

We should expose the most concrete return type on our repository and Template API implementation

@schauder
Copy link
Contributor

Do you want the return types of JdbcAggregateOperations changed as well?

  • Obviously it would be a breaking change. Although, I expect few will be affected.
  • Otherwise we have to introduce a type check and a potential conversion for all the repository methods.

@mp911de
Copy link
Member Author

mp911de commented Sep 25, 2024

Yes, as Iterable on its own is hard to use and in almost all cases, we return some List implementation.

In minor versions we can require calling code to be recompiled.

@mipo256
Copy link
Contributor

mipo256 commented Sep 29, 2024

Obviously it would be a breaking change. Although, I expect few will be affected.

@schauder I do not think it is going to be breaking, though. It is not a problem if the callee that expected Iterable gets List

@schauder
Copy link
Contributor

JdbcAggregateOperations is an interface. Any implementation that actually returns an Iterable would break.

@mp911de
Copy link
Member Author

mp911de commented Oct 1, 2024

While it is possible to follow that line of argument, we also could argue that each change to our interface would prevent us from introducing new methods.

Spring's …Operations interfaces are designated to be implemented by Spring projects. Anyone else implementing such an interface with real code is, with every release, at risk of suffering from catching up. Implementing by inheritance (subclassing …Template that implements …Operations) is the recommended approach. Alternatively, using JDK interface proxies.

@mp911de mp911de added this to the 3.4 M2 (2024.1.0) milestone Oct 1, 2024
@mp911de mp911de closed this as completed in c4f62e9 Oct 1, 2024
mp911de added a commit that referenced this issue Oct 1, 2024
Replace code duplications with doWithBatch(…) method. Return most concrete type in DefaultDataAccessStrategy and MyBatisDataAccessStrategy.

See #1623
Original pull request: #1897
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
3 participants