Spring Data JPA tutorial - Unboxing Spring Data JPA Magic | Spring Boot | JPA | MySQL | Hibernate
HTML-код
- Опубликовано: 8 июн 2024
- In this video, we will unbox the magic of spring data jpa. The Goal here is to understand how Spring Data JPA works internally.
This spring data jpa tutorial will give a step-by-step walkthrough on
1. Build a spring project
2. Configuring Hibernate / JPA / Spring / MYSQL with our Java spring project.
3. Doing CRUD operation with Spring Data JPA
4. Once done, Converting the spring project to Spring Boot
5. Explore spring data jpa with spring boot
6. How spring data JPA works internally
If you want to build a spring boot project that connects to a database, the first thing you will create is a data source.
Datasource in Java holds the connection objects. We can use a DriverManagerDatasource in spring to create a datasource object.
Once the Datasouce setup is done, we can create a EntityManager, which will help us with CRUD operation. EntityManager manages our entities (alternatively called persistence context) and provides a wide range of methods, like persist, remove, find, merge,findAll, etc. This will help us to save, delete, update, and query data from a database.
To create an EnityManager, we can create an EntityManagerFactory first. We only can create an EntityManager from an EntityManagerFactory. In Spring, we need a LocalcontainerEntityManagerFactoryBean to initalize an entity manager factory.
Once the LocalcontainerEntityManagerFactoryBean is set up, then it's time to set up a TransactionManager (PlatformTransactionManager). We can use the JpaTransactionManager to feed it the entity manager factory object to have a fully functional connection setup.
In our DAO, We can use now use an EntityManager with a @PersistenceContext annotation. This will enable us to call the API methods to do CRUD operation.
We can use a @Transactional Annotation on top of our API method to activate and begin/commit the transaction.
Spring Data JPA enables us to automatic repository creation. With the @EnableJpaRepositories we no longer need to write repository classes and the basic CRUD methods to perform data manipulation.
Spring Data JPA will do it all and allows us to have a fully functional CRUD Repository just by extending JpaRepository.
When our custom repository interface extends JpaRepository, it inherits different methods from its super interfaces (CrudRepository, ListCrudRepository, Repository). These methods' implementation is generated in runtime by Spring. Spring Generates this implementation class by using JDK dynamic proxy / AOP proxy.
Data Jpa configuration is so easy when it comes to Spring Boot. We have a one-stop solution to add all the dependencies. We can use a spring boot starter project called "spring boot starter data jpa," and it brings in all the different dependencies that we need to develop a JPA application with spring boot. For MySQL db, we can just add the MySQL driver, and we are ready to go.
We may need to use @EntityScan and @EnableJpaRepositories to scan our Entities and Repository classes.
Let's explore all these concepts in this video! Let's jump right in.
Timestamp
--------------
Introduction - 00:00:00
Build a Maven project - 00:05:34
Building an Entity - 00:07:00
JPA setup - jakarta.persistence-api - 00:08:48
Setting up Repository and EntityManager - 00:13:50
LocalContainerEntityManagerFactoryBean and DataSource setup- 00:23:36
Introducing Hibernate - 00:47:56
Uses of @PersistenceContext - 00:56:42
@Transactional / TransactionManager setup - 01:02:27
Introducing JpaTransactionManager - 01:06:00
EntityManager persist method in action (save) - 01:13:00
Introducing Spring Data JPA - 01:20:00
findAll() implementation with JPA - 01:24:26
Why Spring Data JPA: The Need - 01:29:51
@EnableJpaRepository - 01:37:01
Doing CRUD with Spring Data JPA - 01:38:20
spring data jpa with spring boot - 01:46:19
Spring Boot data jpa autoconfiguration - 01:53:07
@EntityScan - 01:59:04
What's inside the spring-boot-starter-data-jpa dependency?
Activating show-sql in Spring / Spring boot app -02:05:34
The End - 02:07:02
#springdatajpa #springboot #jpa #hibernate
For More free/paid courses visit
www.seleniumexpress.com
LINKS AND FREE LEARNING RESOURCES
========
Watch my new mock interview series for java developers
• Java interview questio...
Watch Spring boot Hot topics
• @Reposicotry Vs @Servi...
Java Interview / Question and Answer series
• Java collections inter...
spring core
• Spring framework tutor...
spring mvc
• Spring MVC course intr...
spring mvc intermediate
• [INTERMEDIATE] Spring ...
For more courses visit
www.seleniumexpress.com
you can ask for support in my website forum
www.seleniumexpress.com
Subscribe to my youtube channel
/ @seleniumexpress
Follow me on Insta
/ selenium_express
Hi. There is a delay in uploading the next scheduled video on Spring Boot Foundation series.
New video coming on this Wednesday. It will be a 10 hours crash course.
Stay tuned to the below playlist for updates
ruclips.net/video/F_rGkDeihBg/видео.html
Have a good day !
excited for upcoming video sir
Waiting
Waiting
When will the video come? We are eagerly waiting for your video
Abhilas when are you going to upload this?
You are the first person on youtube that deliver this type of content. Hats off👏🙌
Thank you for the kind words !! Hope it helps🥰
I don't know why abhilash is sooo underrated.. hope you will get wat you deserve..❤❤
Thank you so much, Ramesh ! 😊
He is a star
First time saw such in depth analysis on jpa
Awesome vedio ❤, I don't think any book gives this much knowledge on Springboot, In single vedio I got know difference between spring and springboot,multiple data base configuration, etc ❤
Nice vidoe !
First time saw such in depth analysis on jpa
Thanks a ton!! This is very awesome and so much informative
Glad you liked it ☺️
Fabulous tutorial, invaluable ...Thanks Abhilash
This explanation is very clear
Thanks for this series.
Welcome! ❤️
Nice to meet you!so interesting shots!Selenium- 💫
Glad you liked it 😊
Thank you very much spring boot guru ji 🙏🙏🙏
My pleasure 😀
Vedio super information macha 🎉 it helps alot for all of us
Glad to hear that ☺️
100th like by me, great job abhilash.
Thank you, Durga !
Thank you
Thank you Abhi❤
My pleasure, Santhosh 😊
Thanks for
Hi Selenium,
One Request, Can you guide or make videos on one to one and other relationship, Where when and which scenario approach should follow to join the tables.
Abhilash, Do you know how to map hibernate entity to postgres json column in Spring boot using data jpa..... also if possible w/o using any external library
Hi is it possible to call a oracle function with output parameters using spring Data JPA?
failed to configure a datasource: 'url' attribute is not specified and no embedded datasource could be configured. reason: failed to determine a suitable driver class action: consider the following: if you want an embedded database (h2, hsql or derby), please put it on the classpath. if you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
We want videos on hibernate mappings please🙏🙏
sir, can you please make a video on oauth2.0
sir, please make videos on spring boot. I have completed the full spring playlist. please upload ASAP SpringBoot playlist.
spring kafka ku video poduga bro
Named query, named native query and jpql not covered in video?
How can we attend your live lectures too?
This is the first video of urs which is confusing me
'Promo sm'