Chapter 4 Generating Hibernate Persistent Objects and JSF Pages
For more convenience, a composite identifier can be implemented as a separate value type class. The primary identifier has just one attribute with the class type. The separate class should be defined as a value type class. Component class mapping will be generated then.
To define component primary identifier mapping:
In the example above, three name attributes are grouped into one separate class Name. It is mapped to the same table as Person class. The generated primary identifier is as follows:
<composite-id name="name" class="identifier.Name">
<key-property name="firstName">
<column name="name_firstName"
sql-type="text"/>
</key-property>
<key-property name="middleName">
<column name="name_middleName"
sql-type="text"/>
</key-property>
<key-property name="lastName">
<column name="name_lastName"
sql-type="text"/>
</key-property>
</composite-id>
Note: The value type class must implement the java.io.Serializable interface, which implements the equals() and hashCode() methods.
| Copyright (C) 2005. Sybase Inc. All rights reserved. |
| |