hibernate.cfg.xml Configuration and Mapping xml Example


A simple hibernate configuration xml file.

  <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"http://www.hibernate.org/dtd/hibernate-configuration-3.3.dtd">

<hibernate-configuration>
   <session-factory>
   <property name="hibernate.dialect">
      org.hibernate.dialect.Oracle10gDialect
   </property>
   <property name="hibernate.connection.driver_class">
      com.mysql.jdbc.Driver
   </property>

   
   <property name="hibernate.connection.url">jdbc:mysql://localhost/myDb</property>
   <property name="hibernate.connection.username">myDbUserName</property>
   <property name="hibernate.connection.password">myPassword</property>

   <!-- Hibernate mannping xmls -->
     <mapping resource="myObject1.hbm.xml"/>
     <mapping resource="myObject2.hbm.xml"/>

  </session-factory>
</hibernate-configuration>



Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.