This is the 14th day of my participation in the First Challenge 2022

Today we are going to take a closer look at JPA and ask why? Why do you often have tears in your eyes, because OF my deep love for this land.

So, today we will love a JPA, why you can define a Repository and use CRUD methods, it must be because other classes reject all.

Repository Bean creates analysis

When we use it, we tag the class with an annotation @EnableJpaRepositories, so let’s click on it and look at the class.

Here’s a JpaRepositoryFactoryBean, what’s the difference between a FactoryBean and a BeanFactory? Ha ha, I understand that FactoryBean creates FactoryBean objects and BeanFactory creates normal Bean objects.

And then we click in and we see a do method,

And then it’s going to create a RepositoryFactorySupport for us

AfterPropertiesSet (); afterPropertiesSet(); afterPropertiesSet();

This method is called when the Bean object is initialized to set some parameter values. Let’s see what happens:

We just call a null class and call the parent class’s method, ok, let’s continue:

Here we create an object that calls the method we mentioned earlier. There are also a lot of parameters assigned, and after the assignment, we see a method like this:

This method takes a repository and returns it. Let’s click on it and see:

This method takes some parameters, and then validates the parameters. Let’s follow up:

So there’s a comment here, and I marked it to create a proxy, so why create a proxy? You might want to add some lookup methods to each repository, or some default method.

As we can see, it adds some interceptors, which we won’t expand here.

This completes the annotation process by fetching a generated repository and returning it

It’s not that hard, is it? Did you learn?