Hibernate Framework Overview: Java Web Application Technologies, Study notes of Computer science

An overview of hibernate, a java framework that simplifies database interactions for java applications. It covers key concepts such as object-relational mapping (orm), java persistence api (jpa), and hibernate architecture. The document also discusses hibernate annotations, mapping java classes to database tables, and different types of association mappings, including unidirectional and bidirectional associations. Additionally, it touches on embedded objects, lazy fetching, and eager fetching strategies, offering a comprehensive introduction to hibernate for java developers. Useful for university students.

Typology: Study notes

2024/2025

Available from 09/04/2025

fabriceish
fabriceish 🇷🇼

11 documents

1 / 60

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Advanced Java by Mrs Larisse 3/18/2025
JAVA WEB APPLICATION
TECHNOLOGIES
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c

Partial preview of the text

Download Hibernate Framework Overview: Java Web Application Technologies and more Study notes Computer science in PDF only on Docsity!

JAVA WEB APPLICATION

TECHNOLOGIES

Hibernate

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. HAn object- relational mapping (ORM) library for Java ● Allows us to interact with a database using regular Java objects ● Provides a closer relationship between your Java objects and tables in your database ● Allows us to easily persist objects in a database ● Works with different database types, and so is an abstraction layer

● Hibernate implements the specifications of JPA (Java

Persistence API) for data persistence

ORM

  • ORM stands for O bject- R elational M apping (ORM) is a programming technique for converting data between relational databases and object oriented programming languages such as Java, C#, etc.

What are Benefits of JPA

JPA - Vendor Implementations

  • For more, read: https://en.wikipedia.org/wiki/Jakarta_Persistence

Hibernate Architecture

❖The Hibernate architecture includes many objects such as :

  • persistent object,
  • session factory,
  • transaction factory,
  • connection factory,
  • Session,
  • transaction etc.

Layers of Hibernate Architecture

  • The Hibernate architecture is categorized in four layers.

Element of Hibernate Architecture

  • SessionFactory: ❖ The SessionFactory is a factory of session and client of ConnectionProvider
  • Session ❖ The session object provides an interface between the application and data stored in the database ❖It is factory of Transaction, Query and Criteria. ❖The org.hibernate.Session interface provides methods to insert, update and delete the object. It also provides factory methods for Transaction, Query and Criteria.

Element of Hibernate Architecture

  • Transaction: ❖ 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.

Hibernate properties

Example of configuration file using XML

Mapping using XML

  • XML-based configuration is one way to define mappings between Java classes and database tables. The mapping is usually defined in a file with a .hbm.xml extension.

Mapping using annotations

Annotations allow you to map entities and their relationships without xml files.

○ All the mapping information will be in the code for each domain/model object
○ Hibernate annotations are the newest way to define mappings without the use of XML file.

You can use annotations in addition to or as a replacement of XML mapping metadata.

○ Hibernate Annotations is the powerful way to provide the metadata for the Object and

Relational Table mapping. All the metadata is clubbed into the POJO java file along with the code, this helps the user to understand the table structure and POJO simultaneously during the development.

○ Hibernate annotations for POJO are contained in JPA through jakarta.persistence package.

The old version of the package was javax.persistence. Src: https://docs.jboss.org/hibernate/jpa/ 2. 2 /api/javax/persistence/package-summary.html