hibernate.cfg.xml Configuration and Mapping xml Example


Posted on : Mon, 7th Dec 15 05:11 pm UTC
2314 votes

A simple hibernate configuration xml file.

hibernate.cfg.xml :
  
<?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>
  

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +