A5 - Concept of JPA,ORM in spring boot,EntityManager and EntityManagerFactory
What is JPA in simple terms?
JPA is higher level standard for interaction with databases.
JPA allows you to use an object model in your application which can make your life much easier.
What is JPA and why it is used?
A JPA (Java Persistence API) is a specification of Java which is used to access, manage, and persist data between Java object and relational database.
OR
Java Persistence API (JPA) is a specification provided by Java for APIs accessing various SQL databases.
It is considered as a standard approach for Object Relational Mapping.
JPA can be seen as a bridge between object-oriented domain models and relational database systems.
What is ORM in spring-boot?
An object-relational mapper (ORM) is a code library that automates the transfer of data stored in relational database tables into objects that are more commonly used in application code.
What is EntityManager in JPA and why is it used?
The EntityManager is an API that manages the lifecycle of entity instances.
An EntityManager object manages a set of entities that are defined by a persistence unit.
The EntityManager API is used to
Create and remove persistent entity instances,
To find entities by their primary key,
To query over entities.
How does Spring Boot define EntityManager?
The complete example of getting EntityManager using the custom configuration in Spring Boot.
Open eclipse and create maven project,
Don't forget to check 'Create a simple project (skip)'
Click on next.
Fill all details(GroupId – entitymanager, ArtifactId – entitymanager and name -entitymanager) and Click on finish.
Following are some of the important roles of an entity manager: -
--> The entity manager implements the API and encapsulates all of them within a single interface.
--> Entity manager is used to read, delete and write an entity.
--> An object referenced by an entity is managed by entity manager.
What is EntityManagerFactory ?
The EntityManagerFactory interface present in java.persistence package is used to provide an entity manager.
Comments
Post a Comment