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

How implement repository without Spring Data? #9

Open
macg20 opened this issue Jul 7, 2022 · 3 comments
Open

How implement repository without Spring Data? #9

macg20 opened this issue Jul 7, 2022 · 3 comments

Comments

@macg20
Copy link

macg20 commented Jul 7, 2022

Hi.Could you explain how to implement FilmRepository without SpringDataJpa and InMemory?
Should FilmRepository be public then? Should the implementation FilmRepository then be in the infrastructure package?
How can I do this while keeping the current package structure and package scope? Could you give an example?

@jakubnabrdalik
Copy link
Owner

Assuming you want to write a wrapper over some primitive tech (like JdbcTemplate or whatever), I'd just implement it directly in the same file. Just like InMemoryRepository.
I know, religious zealots will say right away that this is infrastructure, and therefore should be down in the infra package (thus requiring Repo interface to become public), but I'm agnostic and pragmatic - I give no damn about religion. Everyone understands that Repo is infra, but limiting visibility by package scope is more important (and easy to get wrong).
In fact I have implemented my own version of production ready repos exactly this way (for example to handle thread pools in non-reactive driver with subsribeOn). Worked like a charm, nobody made any mistakes with that for the next 3 years in 2 companies (so no problems for 7 years at least).
But then again, I'm agnostic and pragmatic. I wouldn't be able to do that in a highly religious environment.

@macg20
Copy link
Author

macg20 commented Jul 12, 2022

Thank you for your answer!

@corlaez
Copy link
Contributor

corlaez commented Aug 8, 2022

Tangential to the topic but... I have made a compromise in some cases where repositories where already coded and tested in a different module.
What I did in that case was to mock the repositories. It worked well for my use case of very loosely coupled microservices that just read events and trigger repo calls/create other events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants