Reputation: 11481
I want to add custom behavior to single repository as described in 1.4.1 Adding behaviour to single repositories. In this custom behavior I want to use method already present in my base repository (like save()
or findOne()
method). Ho can I achieve this in Spring data?
I tried extending my UserRepositoryImpl
with SimpleJpaRepository
to have basic SimpleJpaRepository
methods available. But this way I got instantiation problems.
Also using aproach described in 1.4.2 Adding custom behaviour to all repositories doesn't seem like good solution, because it's way too much code for adding one simple method. In this case Spring Data seems more like burden.
Or is it antipatern to add to my repository such simple method which depends on other methods from base repository? Should I rather move this method to service/business layer?
Upvotes: 1
Views: 438
Reputation: 17518
The same question came up a few days ago in this post. As I wrote there as well, I strongly believe this is an antipattern, so my answer to your last question would be a definite yes.
Upvotes: 1