Module 6 Hibernate_Share
Module 6 Hibernate_Share
Hibernate
Hibernate is a Java framework that simplifies the development of Java
application to interact with the database.
It is an open source, lightweight, ORM (Object Relational Mapping) tool.
Hibernate implements the specifications of JPA (Java Persistence API) for
data persistence.
ORM Tool - An ORM tool simplifies the data creation, data manipulation
and data access. It is a programming technique that maps the object to
the data stored in the database.
Session
The session object provides an interface between the application and data stored in the
database. It is a short-lived object and wraps the JDBC connection. It is factory of
Transaction, Query and Criteria. It holds a first-level cache (mandatory) of data. The
org.hibernate.Session interface provides methods to insert, update and delete the object.
It also provides factory methods for Transaction, Query and Criteria.
Transaction
The transaction object specifies the atomic unit of work. It is optional. The
org.hibernate.Transaction interface provides methods for transaction management.
ConnectionProvider
It is a factory of JDBC connections. It abstracts the application from DriverManager or
DataSource. It is optional.
TransactionFactory
It is a factory of Transaction. It is optional. PMCA502L: Thilagavathi M, AP(Sr.), SCORE
Internal API used by Hibernate
JNDI (Java Naming and Directory Interface) is a Java API that provides naming
and directory functionality to applications written in Java. It allows Java
software clients to discover and look up data and objects via a name.
JDBC is Java Database Connectivity API.
The main thing here is that in a JNDI directory you're actually storing a JDBC
DataSource, so, you're simply using JDBC to obtain a Connection via JNDI
lookup.
The Java Transaction API (JTA) allows applications to perform distributed
transactions, that is, transactions that access and update data on two or more
networked computer resources. The JTA specifies standard Java interfaces
between a transaction manager and the parties involved in a distributed
transaction system: the application, the application server, and the resource
manager that controls access to the shared resources affected by the
transactions.
14
Hibernate – Web Application
Create a Maven Project (Refer Project titled ‘mavenproject’)
ControllerServlet
Index.jsp
15
Hibernate – Web Application
CourseDao
PoJO class : Course
Hibernate – Web Application
Util Class
Hibernate – Web Application Output