KEMBAR78
Hibernate_ORM_JPA Hibernate_ORM_JPA.pptx
ORM,JPA,HIBERNATE
1.What is ORM?
2. What is Hibernate and its architecture.
3. What is JPA and how does it work?
Author: Pham Anh Quan
1. WHAT IS ORM?
ORM is a programming technique that helps to transfer data from object to database and vice
versa.
2. What is Hibernate and its architecture.
What is Hibernate?
In the business layer, there are two sublayers, the logic layer and the persistence layer.
Hibernate is one of the ORM Frameworks. Hibernate framework is a framework for persistence layer.
Hibernate architecture.
These are the POJO objects that will map to the corresponding tables of the relational database.
Persistence object
Configuration
The Configuration object provides two main components:
Database Connection: To connect to the database, Configuration uses one or more
configuration files in the form of hibernate.properties
Class Mapping Setup: This component creates connections between Java classes and database
tables.
Session Factory
Sessionfactory in Hibernate is an interface that connects to the Database through reading
Configuration. Each database requires its own Session Factory.
Transaction
A Transaction represents a unit of action to the database
Transaction
A Transaction represents a unit of action to the database
1. WHAT IS JPA?
JPA acts as a mapping between JAVA objects and a relational database
using ORM . technology
JPA acts as a bridge between tables / relationships between tables in the database and
classes / relationships between objects. For example, the USER table with columns (Id,
username, password) will correspond to the User.java class with the fields Id, username,
and password. Since then, every time we query tables or columns, we will directly call
methods on classes and fields of the class without caring about what type of database we
are using, what kind of database data we are using, etc.
JPA architecture
JPA consists of three main components: Entity, EntityManager, and EntityManagerFactory. There are also,
EntityTransaction, Persistence, Query.
Enity
Entities are objects that represent a table in the database. Entities are usually simple
POJO classes, consisting only of getter and setter methods.
Entity Manager
EntityManager is an interface that provides APIs for interacting with Entities.
Some basic functions of EntityManager such as:
Persist: this method is used to save a newly created entity to the database.
Merge: used to update the state of the entity into the database.
Remove: delete an instance of the entity.
EntityManagerFactory
EntityManagerFactory is used to create an instance of EntityManager.
Persistence
A Persistence defines a set of Entity classes that are managed by an instance of
EntityManager in the application.
EntityTransaction
A Transaction is a set of operations where all operations must either be successful or all fail.
A database transaction consists of a set of SQL statements committed or rolled back in a unit.
Query
This is an interface, implemented by each JPA provider to get relational objects that meet the
query criteria.
Reference material:
https://teky.edu.vn/blog/hibernate-la-gi/#Persistence_object
https://t3h.com.vn/tin-tuc/lop-pojo-trong-java#tim-hieu-qua-ve-java-beans-
https://gpcoder.com/6300-gioi-thieu-ve-hibernate/#:~:text=C%C3%A1c%20transaction%20trong%20Hibernate%20%
C4%91%C6%B0%E1%BB%A3c,th%E1%BB%B1c%20hi%E1%BB%87n%20s%E1%BA%BD%20th%E1%BA%A5t%20b%E1
%BA%A1i
.
https://vietnix.vn/orm-la-gi/#:~:text=ORM%20(Object%20Relational%20Mapping)%20l%C3%A0,%2C%20'is%20a’).
https://viblo.asia/p/object-relational-mapping-djeZ1PQ3KWz
https://www.youtube.com/watch?v=wpQEVPRJEu8
https://hocspringboot.net/2020/10/24/hibernate-la-gi-va-cach-cai-dat-trong-spring-boot/
https://viettuts.vn/hibernate/file-mapping-trong-hibernate
https://topdev.vn/blog/tong-quan-ve-jpa-java-persistence-api/
https://stackjava.com/faq/jpa-la-gi-su-khac-nhau-giua-jpa-voi-hibernate.html
Hibernate_ORM_JPA Hibernate_ORM_JPA.pptx

Hibernate_ORM_JPA Hibernate_ORM_JPA.pptx