1. WHAT ISORM?
ORM is a programming technique that helps to transfer data from object to database and vice
versa.
3.
2. What isHibernate 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.
These are thePOJO objects that will map to the corresponding tables of the relational database.
Persistence object
6.
Configuration
The Configuration objectprovides 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.
7.
Session Factory
Sessionfactory inHibernate is an interface that connects to the Database through reading
Configuration. Each database requires its own Session Factory.
1. WHAT ISJPA?
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.
11.
JPA architecture
JPA consistsof three main components: Entity, EntityManager, and EntityManagerFactory. There are also,
EntityTransaction, Persistence, Query.
12.
Enity
Entities are objectsthat represent a table in the database. Entities are usually simple
POJO classes, consisting only of getter and setter methods.
13.
Entity Manager
EntityManager isan 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.
14.
EntityManagerFactory
EntityManagerFactory is usedto 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.
15.
EntityTransaction
A Transaction isa 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.