Reputation: 60
I am using spring data JPA repository, my requirement is when i call repository class methods in service class it should show only custom methods like addUser(X,Y) instead of save().
Any Hack ?
Upvotes: 2
Views: 1812
Reputation: 81940
If you don't want the methods from JpaRepository
or CrudRepository
, don't extend those but just Repository
instead. It is perfectly fine to have a repository interface like
MyVeryLimitedRepository extends Repository<User, Long> {
User findByName(String name);
}
Of course methods like addUser(X,Y)
will need a custom implementation.
Upvotes: 2
Reputation: 1967
You can very well use DAO pattern in this case .
By implementing DAO Pattern in Service Class
You create a wrapper between Service and Repository.
You can custom code your DAO layer to only expose custom methods to service layer
Upvotes: 0