When we are using the hibernate the we also know about that in the mapping class must declare the primary key column of the database table. In the Most classes always having the JavaBeans-style property holding the unique identifier of an instance. The <id> element defines the mapping from that property to the primay key column.
<id
name="propertyName"
type="typename"
column="column_name"
unsaved-value="null|any|none|undefined|id_value"
access="field|property|ClassName">
node="element-name|@attribute-name|element/@attribute|."
<generator class="generatorClass"/>
</id>
Tag
|
Description
|
name(optional)
|
This show the name of the property identifier.
|
type(optional)
|
This indicates the hibernate type.
|
columns(optional)
|
It defaults set on the property name.
Here we use the primary key column.
|
Unsaved-value(optional)
|
It shows the defaults to a “sensible†value.
An idenifier property value that indicates an instance is newly
instantiated (unsaved), distinguishing it from detached instances
that were saved or loaded in a revious session.
|
access(optional)
|
Here we use the defaults property.
The strategy hibernate should use for accessing the property.
|
If the name attribute is missing, that assumed that the class has no identifier property. and the unsaved-value attribute is almost never needed in hibernate3. There is an alternative <composite-id> declaration that allows access to legacy data with composite key. Its use is strongly discouraged for anything else.