Show light on Hibernate mapping file

This is in continuation of my previous post.
Lets take the hibernate mapping file and get to the tags used in that file.
<?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> <class name="hib.Contact" table="CONTACT"> <id name="id" type="long" column="ID" > <generator/> </id> <property name="firstName"> <column name="FIRSTNAME" /> </property> <property name="lastName"> <column name="LASTNAME"/> </property> <property name="email"> <column name="EMAIL"/> </property> </class> </hibernate-mapping>
We could see some XML tags tries forms this mapping. Their explanations are given below.
hibernate-mapping
Root element of this mapping
class
maps the java class and SQL table
id
This will handle the primary key constraint. In addition this is the unique representation of an object.
Attributes of ID elements are given below.
name:
The property name used by the persistent class.
column:
The column used to store the primary key value.
type:
The Java data type used.
unsaved-value:
This is the value used to determine if a class has been made persistent. If the value of the id attribute is null, then it means that this object has not been persisted.
generator
This is the notification to generate the primary key. The following values to this attribute decides the type of generator
Increment:
generate primary keys of type long, short or int that are unique only. It should not be used in the clustered deployment environment.
Sequence:
Hibernate can also use the sequences to generate the primary key. It can be used with DB2, PostgreSQL, Oracle, SAP DB databases.
Assigned
Assigned method is used when application code generates the primary key.
property
The property elements define standard Java attributes and their mapping into database schema. The property element supports the column child element to specify additional properties, such as the index name on a column or a specific column type
[...] Show light on Hibernate mapping file » [...]