Chapter 4 Generating Hibernate Persistent Objects and JSF Pages


Mapping to multiple tables

A class can be mapped to multiple tables. In the following, the first mapped class source is the master class source. The primary identifier of the class is mapped to the master class source. All the other classes are secondary tables, which should have a reference key referring to the master table. If this is not the case, a default reference key will be generated. Views cannot have a reference key, and cannot be secondary tables.

Join mappings will be generated for a secondary table if there is any attribute mapped to a column of the table.

Steps To map one class to multiple tables:

  1. Define O/R mapping for the class.
  2. Open the class property sheet and select the Mapping tab.
  3. Click the Add tool to add another table.
  4. Select the Attribute Mappings tab
  5. Select the columns that you want to map to.


 


Copyright (C) 2005. Sybase Inc. All rights reserved.