Show TOC Start of Content Area

Procedure documentation Mapping Persistent Fields (cmp-fields)  Locate the document in its SAP Library structure

Mapping Persistent Fields to Columns in the Database Table

...

       1.      Open persistent.xml theEnterprise Beans tab

       2.      Choose the corresponding bean cmp-field the persistent field you want to map.

Enter the following data:

Property

Description

Column name

Choose a column from the drop-down list.

The list contains the names of the columns in the database table to which the container-managed entity bean is mapped.

The system will display a verification message.

Database column type

Choose between NoKey (the default option – indicates that the column is not a key) and UniqueKey (used only if you use the CREATE_TABLES shell command to create your tables).

If the persistent field is defined as a primary key, the value of this field is set to PrimaryKey by default and you will not be able to change it.

Map to single column

Use this option if you want to map your dependent-value persistent field to a single column in the database table. In this case, the value of the cmp-field is serialized to a byte array.

This option is enabled only if the selected cmp-field is a dependent-value class.

This graphic is explained in the accompanying text

On this screen you cannot modify the Java type of the persistent field and the name of the table, to which the entity bean is mapped.

Mapping a Compound Primary Key

The mapping of persistent fields, which are part of a compound primary key of a container-managed entity bean, does not differ from mapping an ordinary persistent field. When you map the corresponding cmp-field to a column, you must select a column that is set to be a key in the database table.

This graphic is explained in the accompanying text

The database table to which you have mapped your bean must contain the same number of key columns as the number of persistent fields, which are part of the compound primary key.

The Database column type field is set to PrimaryKey for all persistent fields participating in the compound primary key and cannot be modified.

Mapping Dependent-Value Persistent Fields

If your persistent field is a dependent-value field, you can map it to:

·        A single column – choose the Map to single column option and choose the column name from the Column name drop-down list and the database column type.

·        A set of columns

...

                            a.      Open the dependent-value cmp-field sub-tree and select the corresponding field.

                            b.      In the right-hand pane, choose the Field is persistent option.

If you do not want the value of this field to be stored in the database (that is, your field is not persistent), do not select this option.

                            c.      From the Column name drop-down list, choose the name of the column, to which you want to map this field.

The system displays a confirmation message.

 

 

End of Content Area