Who implements the Spring Repository interfaces?

Asked

Viewed 75 times

2

We have the interface JpaRepository which we can use from your import with:

import org.springframework.data.jpa.repository.JpaRepository;

From it we have the standard methods to use, such as the findAll(). We can also create new methods only by signing, for example findByPessoaName(String nome);

But who performs all the implementation of this interface JpaRepository and those other methods that I put only the signature and the Spring generates automatically? Is it Hibernate (assuming I’m using it) or Spring Data itself? I know that Spring Data JPA uses Hibernate as the implementation of the JPA specification by default, but Hibernate itself knows how to implement these standards methods?

1 answer

2


Are the Annotations of the Spring that do the magic.

When you wear the @Autowired, Spring locates your interface, creates 1 class and implements everything.

This is all done with Annotations and Reflection.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.