Sponsered Links
Categories
Sponsered Links

Hibernate XML mapping of the Category class

 

  1. The Hibernate mapping DTD should be declared in every mapping file; it’s required for syntactic validation of the XML.
  2. Mappings are declared inside a <hibernate-mapping> element. You can include as many class mappings as you like, along with certain other special declarations.
  3. The class Category (in the package org.hibernate.auction.model) is mapped to the table CATEGORY. Every row in this table represents one instance of type Category.
  4. We haven’t discussed the concept of object identity, so you may be surprised by this mapping element. To understand this mapping, it’s sufficient to know that every record in the CATEGORY table will have a primary key value that matches the object identity of the instance in memory. The <id> mapping element is used to define the details of object identity.
  5. The property name of type String is mapped to a database column NAME. Note that the type declared in the mapping is a built-in Hibernate type (string), not the type of the Java property or the SQL column type. Think about this as the “mapping data type.”

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="org.hibernate.auction.model.Category"
table="CATEGORY">
<id
name="id"
column="CATEGORY_ID"
type="long">
<generator class="native"/>
</id>
<property
name="name"
column="NAME"
type="string"/>
</class>
</hibernate-mapping>

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved