-
Notifications
You must be signed in to change notification settings - Fork 669
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
Provide a dedicated read-only repository interface [DATACMNS-1638] #2064
Comments
Oliver Drotbohm commented This has been discussed a couple of times already and so far we've shied away from introducing additional repository base interfaces as the situation is far from trivial. Let me elaborate a bit. The hierarchy of repository interfaces as non-trivial alreadyThe repository hierarchy already contains quite a few interfaces for users to choose from: – Providing even more of those complicates the picture significantly as we have to explain the tradeoffs for each interface we provide. The more we get opinionated about that the higher the chance that some of the interface almost meets a user's expectations but then again does not quite. We've had requests to remove the As a side note: interestingly we've seen your request from a different angle. Users asking for a repository not containing find operations other than Most applications craft their own base interface anywayThis is usually done for multiple purposes: one important one is to minimize the number of places with a fundamental Spring Data dependency in the codebase. Another one is aligning all repositories on a certain identifier type. A third one is slightly tweaking return values for common operations (e.g. returning Changing the interface hierarchy is a breaking changeIntroducing an interface in between Also, we'd have to answer the question what interface ConcludingI wonder how far we could get if we started with a mini library existing outside Spring Data that could try different arrangements based on |
Vitor Carvalho commented Thanks for the explanation and actually I agree with everything you said. Regarding this part "Introducing an interface in between I didn't quite understand the concluding part though. Are you suggesting to have a separate library to "pack" all these commonly requested dedicated repositories? Like, having a ReadOnlyRepository, and a NoFindRepository, and a WithoutCountRepository, and others that are commonly requested? |
Oliver Drotbohm commented Yes, a separate library would allow us to explore which subsets of repositories might make sense, alter those as feedback is coming in. Once we gained a bit more confidence, we can then move them over into Spring Data proper |
Vitor Carvalho commented Looks like a good plan to me. How can we proceed? |
Oliver Drotbohm commented Care to throw the interfaces you have into a repo at Github? Preferably accompanied by a few tests that make use of them to show that the CRUD methods still do what they're supposed to. We can then beat the drum for people to use them and see how it goes |
Vitor Carvalho commented Sorry for the delayed response. Didn't had much free time unfortunately. |
Duplicates #2610. |
Based on discussions with the team, we have decided NOT to implement this. However, you are free to implement it locally in your own project. Check out this part of the ref docs, where you can see how to define a base repository of your own, e.g. ReadOnlyRepository (or ReadingRepository) where you could have only read-based operations. |
Vitor Carvalho opened DATACMNS-1638 and commented
Whenever a developer needs to create a read only repository, it has to extend the Repository interface and then add all the read methods from CrudRepository to it.
It would be useful to have a ReadRepository similar to CrudRepository with all the read only methods.
No further details from DATACMNS-1638
The text was updated successfully, but these errors were encountered: