Component and dynamic-component in Hibernate by R4R Team

In Hibernate we found some component tag which is used for mapping. The <component> element maps to properties of a child object of the columns of the table of a parent class. We know that component can declare their own properties.


Example:

<component 

name="propertyName"

class="className"

insert="true|false"

update="true|false"

access="field|property|ClassName"

lazy="true|false"

optimistic-lock="true|false"

unique="true|false"

node="element-name|." > 

<property ...../> <many-to-one .... /> ........ </component>


Tag

Description

name

It shows the property name.

class(optional)

It found defaults to the property type of determined by reflection.

It use the name of the componant(child) class.

insert

It is used to mapped column appear in SQL INSERTs

update

It is used to mapped columns appear in the SQL UPDAE

access(optional)

It found the property defaults.

In this strategy Hibernate uses for accessing the property value.

lazy(optional)

It defaults to false.

It specifies the componant should be fetched lazily when the instance variable is first accessed. It requries build-time bytecode instrumentation.

optimistic-lock(optional)

It defaults to true.

It specifices that updates to this componant either do or do not require acquisition of the optimistic lock. It determines if a version increment should occur when this property is dirty.

unique(optional)

It found the defaults to false.

It specifies that a unique constraint exists upon all mapped columns of the componant.


The child <property> tags map properties of the child class to table columns. The <component> element allows a <parent> sub element that maps a property of the component class as a reference back to the containing entity. The <dynamic-component> element allows a Map to be mapped as a component, where the property names refer to keys of the map. 

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!