Component Mapping In Hibernate with XML
If we want to store one class object at a value of another class object, then we use component mapping.
To use Component mapping the two classes should have 'has-a' relation between
them.
In hbm file to map a Component to a table of a database then we have
<Component> tag.
Ex : public class Employee{
int id;
String name;
Address address;
}
class Address{
int hno;
String street;
String city;
}
hbm file:
======================================
<hibernate-mapping>
<class name="hibernate1.Student" table="finalst">
<id name="id"></id>
<property name="name"></property>
<component name="address">
<property name="hno"/>
<property name="street"/>
<property name="city"/>
</component>
</class>
</hibernate-mapping>
=====================================
short nd sweet thanks sir............
ReplyDelete