Is there a way to apply a default filter/predicate on all queries that are generated by a JpaRepository, to automatically restrict the results. For example, if I implement a soft-delete flag, I want to automatically exclude those results from all further selects.
Hibernate is the JPA implementation beneath, if that helps.
You can create your own repository that extends SimpleJpaRepository. Then implement RepositoryFactoryBean and RepositoryFactory that will return repositories containing your implementation. For JPA you can base on the example under https://github.com/jkubrynski/spring-data-examples/tree/master/src/main/java/com/kubrynski/data/repository/generic
Remember about enabling your factorybean in @EnableJpaRepositories by specifying repositoryFactoryBeanClass.
See here where there is the answer to your question (basically using the
@Where
annotation). You could also use hibernate filters but the answer I linked above is more than enough.Even if your question is old I write here for future reference.