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.
|