Chapter 4 Generating Hibernate Persistent Objects and JSF Pages


Defining entity type and value type classes

There are two kinds of classes in Hibernate, entity classes and value type classes. Entity classes have their own database identities, mapping files and life cycles, while value type classes don't have. Value type classes depend on entity classes. Value type classes are also called component classes.

We use an extended attribute ValueType to indicate whether the class is value type or not. The default value is false. You can set ValueType value in Class property sheet Hibernate tab.

Steps To define a value type class for an entity class:

  1. Create a value type class, and define its attributes but not a primary identifier.
  2. In the Hibernate tab, select Value type.
  3. Create an entity class.
  4. Add an attribute.
  5. Open the attribute property sheet, click the Details tab, and set the Class generation type to Embedded.
  6. Do not define an explicit attribute mapping for this attribute.

When generating a PDM from an OOM, a class used as attribute data type can be generated as an embedded class: its attributes will be generated as columns of the table that is generated for the class containing the attribute.

You can also define component class mappings with association mapping. Classes on association ends are generated as component class mappings. See "Defining Hibernate Association Mappings" for more details.

 


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