3
votes

We have lots of repositories defined via the interface extends JpaRepository pattern. When running integration tests or certain entry points to our application, we only need a very small subset of those repositories.

Can we lazily load the actual repository implimentations?

Something equivalent to @Lazy on a @Bean? Note: I did at least attempt the naive solution of annotating the repository interface with @Lazy to no avail.

2

2 Answers

2
votes

Even if it's a very old Question, I think some may still want to know about the use of @Lazy on Spring Data repositories :

it is actually supported since v1.5.0

0
votes

Lazyloading will avoid to get all other dependency based on your main table or request. In your case you should set a limit / offset for that kind of operation.