HIBERNATE TUTORIAL

HIBERNATE - Hibernate O/R Mapping

This section will explain how to write the mapping documents manually. Although there are tools available to create these mapping documents, learning how to create these documents manually helps in fine tuning and setting up advance table mapping.

Mapping Declaration

Object/relational mappings are usually defined in XML document. The mapping language is Java-centric, meaning that mappings are constructed around persistent class declarations, not table declarations.

Mapping Document
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.somepackage.eg">
 

<class name="Foo" table=”FooTable”>

   

<id name="id" type=”java.lang.Long”>

      <generator class=”sequence”/>
    </id>
  </class>
</hibernate-mapping> 


The above example shows a typical mapping document that contains class mapping with table.
All mapping XML document should refer to hibernate-mapping-3.0.dtd via doctype.


 

Hibernate tutorial
Introduction to Hibernate
Overview of Hibernate
Features of Hibernate
Getting Started with Hibernate
Hibernate O/R Mapping

Mapping declaration

Mapping Document
<hibernate-mapping> element
<class> element
<id> element
<generator> element
<property> element
<many-to-one> element
<one-to-one> element
Hibernate Mapping In Depth
Hibernate Query Language
Hibernate Complete Example

Use of this website constitutes acceptance of the AllAppLabs.com Terms and Conditions