SlideShare a Scribd company logo
1 of 9
Download to read offline
Hibernate
Framework
Hibernate
Hibernate is an Object-Relational Mapping (ORM) framework for Java. It
provides a way to map Java objects to relational database tables, and vice versa.
It also provides a powerful query language (HQL) for retrieving and
manipulating data, as well as a number of other features for managing the
persistence of Java objects. Hibernate is commonly used in enterprise
applications to abstract away the complexity of working with a relational
database and to provide a more object-oriented way of working with data.
How to create Hibernate Project?
1. Create a maven project.
2. In pom.xml add jdbc and hibernate dependencies using below link:
a. https://mvnrepository.com/
3. Create hibernate configuration xml in src/main/java for database
configuration.
4. Create your required classes in you package.
What is Catalog,Group id and Artifact id
In a Maven project, a "catalog" refers to a collection of related projects. The "groupId" and
"artifactId" are two important pieces of information used to identify a project within a catalog.
The "groupId" is a unique identifier for a project's group or organization. It typically follows a
reverse-domain-name convention, such as com.example.myproject. The "groupId" is used to
group related projects together, and it forms part of the project's fully-qualified name.
The "artifactId" is a unique identifier for a specific project within a group. The "artifactId" is used
to distinguish different versions of the same project, and it forms part of the project's
fully-qualified name.
Together, the "groupId" and "artifactId" form the "coordinates" of a project in a Maven catalog.
The coordinates are used to specify a project's dependencies, and they are also used to locate the
project's artifacts (e.g. JAR files) in a Maven repository.
Use of pom.xml
The pom.xml (short for "Project Object Model") is an XML file that contains information about a Maven
project. It is used to configure the project's build, dependencies, plugins, and other settings. The pom.xml
is typically located in the root directory of a Maven project.
The main use of the pom.xml is to define the project's dependencies. A dependency is a library or module
that a project needs in order to build and run correctly. In the pom.xml, dependencies are defined in the
<dependencies> section. Each dependency is defined by its groupId, artifactId, and version. Maven uses
this information to locate the dependency in a Maven repository and to download the dependency to the
local machine.
The pom.xml also contains information about the project's build settings, such as the project's name,
description, and version. Plugins are used for tasks such as compiling code, running tests, and creating a
JAR or WAR file.
In short, the pom.xml serves as a central place to configure all aspects of a Maven project, and it is
essential for the proper functioning of a Maven build.
Use of
hibernate.cfg.xml
The hibernate.cfg.xml (also known as the Hibernate
configuration file) is an XML file that contains
configuration settings for a Hibernate-based
application. It is typically located in the classpath of
the application and is used to configure the Hibernate
SessionFactory, which is the main entry point to the
Hibernate API.
The main use of the hibernate.cfg.xml is to configure
the connection to the database. It contains
information such as the JDBC driver class, the
database URL, the username, and the password. It
also contains information about the dialect of SQL
that the database uses, which allows Hibernate to
generate appropriate SQL statements for the
database.
The hibernate.cfg.xml also contains other settings
related to Hibernate's behavior, such as the cache
strategy, the current session context, and the
transaction factory. It also contains the mapping of
Java classes to database tables, through the use of
<mapping> element or by specifying the package
containing the entity classes.
hibernate.cfg.xml
<session-factory>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQL8Dialect</property>
<property
name="hibernate.connection.url">jdbc:mysql://localhost:3306/db</property>
<!-- 'show_sql' set true to check sql statements on console else set to false
-->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!-- use 'create' to Create tables on application startup else use 'update'-->
<property name="hbm2ddl.auto">update</property>
</session-factory>
Hibernate classes overview
The Configuration object is used to configure the SessionFactory.
The SessionFactory is used to create and manage sessions.
A session represents a single unit of work with the database and is used to perform operations on
the database and on persistent objects.
The SessionFactory is a thread-safe object that is responsible for creating and managing sessions
and other objects used by Hibernate.
The Configuration is used to create the SessionFactory and it is used to specify the properties of
the SessionFactory, such as the database connection properties and Hibernate properties.
Hibernate.pdf

More Related Content

Similar to Hibernate.pdf

Hibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersHibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersAnuragMourya8
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.suranisaunak
 
Patni Hibernate
Patni   HibernatePatni   Hibernate
Patni Hibernatepatinijava
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaEdureka!
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginnersRahul Jain
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questionsDhiraj Champawat
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking TourJoshua Long
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_entechbed
 
Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deploymentelliando dias
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3Oracle
 

Similar to Hibernate.pdf (20)

Spring 2
Spring 2Spring 2
Spring 2
 
Hibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersHibernate Interview Questions and Answers
Hibernate Interview Questions and Answers
 
What is hibernate?
What is hibernate?What is hibernate?
What is hibernate?
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.
 
Patni Hibernate
Patni   HibernatePatni   Hibernate
Patni Hibernate
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | Edureka
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginners
 
TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions
 
Hibernate 3
Hibernate 3Hibernate 3
Hibernate 3
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking Tour
 
Introduction to Hibernate
Introduction to HibernateIntroduction to Hibernate
Introduction to Hibernate
 
Hibernate
HibernateHibernate
Hibernate
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
 
Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deployment
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3
 

Recently uploaded

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 

Recently uploaded (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 

Hibernate.pdf

  • 2. Hibernate Hibernate is an Object-Relational Mapping (ORM) framework for Java. It provides a way to map Java objects to relational database tables, and vice versa. It also provides a powerful query language (HQL) for retrieving and manipulating data, as well as a number of other features for managing the persistence of Java objects. Hibernate is commonly used in enterprise applications to abstract away the complexity of working with a relational database and to provide a more object-oriented way of working with data.
  • 3. How to create Hibernate Project? 1. Create a maven project. 2. In pom.xml add jdbc and hibernate dependencies using below link: a. https://mvnrepository.com/ 3. Create hibernate configuration xml in src/main/java for database configuration. 4. Create your required classes in you package.
  • 4. What is Catalog,Group id and Artifact id In a Maven project, a "catalog" refers to a collection of related projects. The "groupId" and "artifactId" are two important pieces of information used to identify a project within a catalog. The "groupId" is a unique identifier for a project's group or organization. It typically follows a reverse-domain-name convention, such as com.example.myproject. The "groupId" is used to group related projects together, and it forms part of the project's fully-qualified name. The "artifactId" is a unique identifier for a specific project within a group. The "artifactId" is used to distinguish different versions of the same project, and it forms part of the project's fully-qualified name. Together, the "groupId" and "artifactId" form the "coordinates" of a project in a Maven catalog. The coordinates are used to specify a project's dependencies, and they are also used to locate the project's artifacts (e.g. JAR files) in a Maven repository.
  • 5. Use of pom.xml The pom.xml (short for "Project Object Model") is an XML file that contains information about a Maven project. It is used to configure the project's build, dependencies, plugins, and other settings. The pom.xml is typically located in the root directory of a Maven project. The main use of the pom.xml is to define the project's dependencies. A dependency is a library or module that a project needs in order to build and run correctly. In the pom.xml, dependencies are defined in the <dependencies> section. Each dependency is defined by its groupId, artifactId, and version. Maven uses this information to locate the dependency in a Maven repository and to download the dependency to the local machine. The pom.xml also contains information about the project's build settings, such as the project's name, description, and version. Plugins are used for tasks such as compiling code, running tests, and creating a JAR or WAR file. In short, the pom.xml serves as a central place to configure all aspects of a Maven project, and it is essential for the proper functioning of a Maven build.
  • 6. Use of hibernate.cfg.xml The hibernate.cfg.xml (also known as the Hibernate configuration file) is an XML file that contains configuration settings for a Hibernate-based application. It is typically located in the classpath of the application and is used to configure the Hibernate SessionFactory, which is the main entry point to the Hibernate API. The main use of the hibernate.cfg.xml is to configure the connection to the database. It contains information such as the JDBC driver class, the database URL, the username, and the password. It also contains information about the dialect of SQL that the database uses, which allows Hibernate to generate appropriate SQL statements for the database. The hibernate.cfg.xml also contains other settings related to Hibernate's behavior, such as the cache strategy, the current session context, and the transaction factory. It also contains the mapping of Java classes to database tables, through the use of <mapping> element or by specifying the package containing the entity classes.
  • 7. hibernate.cfg.xml <session-factory> <property name="connection.username">root</property> <property name="connection.password">root</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="dialect">org.hibernate.dialect.MySQL8Dialect</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/db</property> <!-- 'show_sql' set true to check sql statements on console else set to false --> <property name="show_sql">true</property> <property name="format_sql">true</property> <!-- use 'create' to Create tables on application startup else use 'update'--> <property name="hbm2ddl.auto">update</property> </session-factory>
  • 8. Hibernate classes overview The Configuration object is used to configure the SessionFactory. The SessionFactory is used to create and manage sessions. A session represents a single unit of work with the database and is used to perform operations on the database and on persistent objects. The SessionFactory is a thread-safe object that is responsible for creating and managing sessions and other objects used by Hibernate. The Configuration is used to create the SessionFactory and it is used to specify the properties of the SessionFactory, such as the database connection properties and Hibernate properties.