Hibernate Configuration :-
- It is an XML file where we descibe database connection details (username, password, url, driver class name).
- There we are declare Hibernate Properties like dialect, show_sql, second-level-cache ,hbm2ddl.auto.. etc
- Hibernate uses this file to establish connection to the particular database server.
- For each database we must create one hibernate configuration file.
- Suppose if we want to connect two databases, like Oracle and MySql, then we must create 2 configuration files.
- We can execute hibernate.cfg.xml from following way :-
Configuration cfg=new Configuration(); cfg.configure(“hibernate.cfg.xml“);
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@localhost:1521:xe
system
oracle
org.hibernate.dialect.Oracle9Dialect
update
true
true
Here we are declare table and column in XML type which is describe inside employee.hbm.xml file this will be call from mapping resource inside Hibernate.cfg.xml.
We are declare table and column in an entity class from annotation base.it will be call from mapping class inside Hibernate.cfg.xml.