Manual
1. Create the hibernate.cfg.xml file in the EmployeeInfo/src directory, as explained
in the Creating the Hibernate Mapping File section.
NOTE: By default, XML files open in the XML Editor. The XML Editor has two views:
Design and Source view. Select the Source view.
2. To modify the hibernate.cfg.xml file, complete the following steps:
• Add reference for the Hibernate mapping file under <session-factory> tag.
<mapping resource="Employee.hbm.xml" />
• Add reference for the Hibernate dialect file by including the following property tag
under <session-factory> tag.
<property name="dialect">
org.hibernate.dialect.SqlmxDialect
</property>
• Enable auto-creation of database tables using the Hibernate mapping file by including
the following property tag under the <session-factory> tag.
<property name="hibernate.hbm2ddl.auto">create</property>
After modification, the hibernate.cfg.xml file appears as:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="show_sql">true</property>
<!-- SQL Dialect to use. Dialects are database specific -->
<property name="dialect">
org.hibernate.dialect.SqlmxDialect
</property>
<!-- Mapping files -->
<mapping resource="Employee.hbm.xml" />
</session-factory>
</hibernate-configuration>
hibernate.properties
The hibernate.properties file contains the SQL/MX database details.
To create the hibernate.properties file, complete the following steps:
1. On the Project Explorer frame, right-click EmployeeInfo and select New > File.
The New File dialog box appears.
2. Change the parent folder to the EmployeeInfo/src directory. In the File name field, enter
hibernate.properties. Click Finish.
The hibernate.properties file is created.
Figure 17-14 shows the New File dialog box.
346 Getting Started with Hibernate