HIBERNATE Questions and Answers

What is a hibernate xml mapping document and how does it look like?

In order to make most of the things work in hibernate, usually the information is provided in an xml document. This document is called as xml mapping document. The document defines, among other things, how properties of the user defined persistence classes’ map to the columns of the relative tables in database.
<?xml version=”1.0″?> <!DOCTYPE hibernate-mapping PUBLIC
<class name=”sample.MyPersistanceClass” table=”MyPersitaceTable”>
<id name=”id” column=”MyPerId”> <generator class=”increment”/>
<property name=”text” column=”Persistance_message”/>
<many-to-one name=”nxtPer” cascade=”all” column=”NxtPerId”/>
Everything should be included under <hibernate-mapping> tag. This is the main tag for an xml mapping document.