Chapter 4 Generating Hibernate Persistent Objects and JSF Pages


Mapping collections of value types

For Hibernate, there are two types of classes:

If there is a value type class on the navigable role side of an association with a multiplicity of one, PowerDesigner will embed the value type in the entity type as a composite attribute.

Steps To map collections of value type:

  1. Create an entity type and a value type class.
  2. Create an association between them. On the value type side, set the multiplicity to one and the navigability to true.
  3. Open the property sheet of the value type class, and click the Hibernate tab.
  4. Check the Value type checkbox.
  5. Generate the PDM with O/R mapping.
  6. Open the property sheet of the entity class and click the Preview tab.
  7. Verify the mapping file.

A composite entity class may contain components, using the <nested-composite-element> declaration.

Steps To define association collection type for one-to-many or many-to-many associations:

  1. Open the association property sheet and click the Detail tab.
  2. Specify a Multiplicity on both sides.
  3. Specify either unidirectional or bi-directional navigability.
  4. Specify role names if necessary.
  5. If one role of the association is navigable and the multiplicity is many, you can set the collection container type and batch loading size.
  6. If you select java.util.List or <none>, it implies that you want to use an array or list-indexed collection type. Then you should define an index column to preserve the objects collection order in the database.

Note: The Java collection container type conditions the Hibernate collection type.

Collection Container Type Hibernate Collection Type
<None> array
java.util.Collection bag or idbag (many-to-many)
java.util.List list
java.util.Set set

 


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