Id in Basic O/R Mapping of Hibernate by R4R Team

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.
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!