What is component mapping in hibernate?
By: Emiley J. Printer Friendly Format
A component is a contained object that is persisted as a value type ,not an entity reference.
Example:
public class person{
private Name name;
public Name getName(){ return name;}
public void setName(Name
name){this.name=name;}
.....
}
public class Name
{chat initial;
String first;
String last;
public char getInitial(){return
initial;}
public void setInitial(char
initial){this.initial=initial;}
.......//first,last
}
Now 'Name' may be persited
to the component of 'person'
in hbm:
<class name="eg.Person" table="person"> <id name="Key" column="pid" type="string"> <generator class="uuid"/> </id> <property name="birthday" type="date"/> <component name="Name" class="eg.Name"> <!-- class attribute optional --> <property name="initial"/> <property name="first"/> <property name="last"/> </component> </class>
The person table would have the
columns pid,
birthday,
initial,
first
and last.
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
Primary keys assigned by triggers in Hibernate
Assigned identifiers in Hibernate
Identity columns and sequences in Hibernate
EntityNameResolvers in Hibernate
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
equals() and hashCode() in Hibernate
Fetching strategies in Hibernate
Creating Connection Pool for JDBC Connections in Hibernate
Hibernate JDBC and Connection Properties
Hibernate Transaction Properties
Archived Comments
1. Brettkip
View Tutorial By: Brettkip at 2017-06-03 21:33:33