Issue
I have the following question for the community: is there any way to customize the 'find' logic for all my JPA repositories?
For example, I would like my custom 'find' logic to be invoked automatically everytime a method containing the word 'find' is created in my JPA repositories (findAll, findById, findOne, ..).
I'm trying to follow the official documentation (https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.customize-base-repository) but I don't understand if I'm doing something wrong or if it's not possible to implement what I have in mind with this straregy.
Thank you in advance.
Solution
You can do it with the use of Spring AOP
(I suggest you read the docs). When using annotations, your pointcut expression (inside an aspect) would look like so:
@Pointcut("execution(*org.yourpackage.repositories.*.find*(..))")
public void customFind() {
//...
}
Answered By - k-wasilewski