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>

This is not an AI-generated article but is demonstrated by a human.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!