There are mainly six important tags for hibernate configuration file. Hibernate configuration file naming convension is generally hibernate.cfg.xml and it is generally placed in the classpath. This can also be configured in the hibernate.properties file. If both hibernate.cfg.xml and hibernate.properties are found in the classpath then hibernate.cfg.xml overrides hibernate.properties file.
The important tags are as follows:

DTD

<?xml versi encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

 

JDBC Configuration

<property name="connection.driver_class">db_driver(com.mysql.jdbc.Driver)</property>
<property name="connection.url">db_connection_url(jdbc:mysql://localhost:3306)/db_name</property>
<property name="connection.username">db_username</property>
<property name="connection.password">db_password</property>

 

SQL variant generation

<property name="dialect">db_dialect(org.hibernate.dialect.MySQLDialect)</property>

 

Connection pool size

<property name="hibernate.connection.pool_size">10</property>

 

Automatic generation of database schema

<property name="hibernate.hbm2ddl.auto">create-drop</property>

 

Mapping files

<mapping resource="com/garnaik/classified/pojo/Department.hbm.xml"/>
<mapping resource="com/garnaik/classified/pojo/Employee.hbm.xml"/>

 

Thanks for your patience. If you have any question please write to me.

Tags:

I am a professional Web developer, Enterprise Application developer, Software Engineer and Blogger. Connect me on Roy Tutorials | TwitterFacebook Google PlusLinkedin | Reddit

Leave a Reply

Your email address will not be published. Required fields are marked *