Example & Tutorial understanding programming in easy ways.

How will you configure Hibernate?

When we want to work with the hibernate application then we have to Configure that application into the Hibernate application.  Every configuration file contains three type of information that are:
        Connection Properties
        Hibernate Properties
        Mapping File Name
-> We need to create one single configuration file for each database that we want to use, suppose if we want to connect with two database those are (Oracle,MySql) then we have to making two configuration for both databases.
                        No. of Databases that we are using = No of Configuration file.
We can use to these configuration in two ways:
        xml
        By writing Properties file.
We don’t have annotations here, actually in hibernate 1, 2.x we defined this configuration file by writing .properties file, but from 3.x xml came into picture.
So,
        Configuration -> xml, .properties (old style)

Syntax of Configuration with xml file: 

<hibernate-configuration>

<session-factory>

<property name="connection.driver_class">Driver Class Name property>

<property name="connection.url">URLproperty>

<property name="connection.user">userproperty>

<property name="connection.password">passwordproperty>

<property name="show_sql">true/falseproperty>

<property name="dialet">Database dialet classproperty>

<property name="hbm2ddl.auto">create/update or what everproperty>

<mapping resource="hbm file 1 name .xml" / >

<mapping resource="hbm file 2 name .xml" / >

session-factory>

hibernate-configuration>


Read More →