Easy learning with example program codes

Hibernate configuration file

As we discussed that hibernate works as an intermediate layer between java application and relational database. So hibernate needs some configuration setting related to the database and other parameters like mapping files. A hibernate configuration file contains all such information.

A hibernate configuration file mainly contains three types of information:

  1. Connection Properties related to the database.
  2. Hibernate Properties related to hibernate behaviour.
  3. Mapping files entries related to the mapping of a POJO class and a database table.

How to create a hibernate configuration file?

We can create a hibernate configuration file either by using java properties file known as or by using an xml file known as hibernate.cfg.xml. The hibernate.cfg.xml file is used mostly.

Note: No. of hibernate configuration files in an application is dependence upon the no. of database uses. No. of hibernate configuration files are equals to the no. of database uses.


  // Connection Properties
  <property name="connection.driver_class">driverClassName</property>
  <property name="connection.url">jdbcConnectionURL</property>
  <property name="connection.user">databaseUsername</property>
  <property name="connection.password">databasePassword</property>
  // Hibernate Properties
  <property name="show_sql">true/false</property>
  <property name="dialet">databaseDialetClass</property>
  <property name="">like create/update</property>
  // Mapping files entries
  <mapping resource="mappingFile1.xml" />
  <mapping resource="mappingFile2.xml" />

Next Topic: Persistent class with example.
Previous Topic: Hibernate architecture.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki