Show TOC

Creating Database Tables and Generating EntitiesLocate this document in the navigation structure

Use

This procedure describes how you create database tables manually and use the entity generation function (also called “backward mapping” ).

  • If you are using the system database, you have to define the tables in Java Dictionary.

    For more information about Java Dictionary, see Providing Java Dictionary Tables and Data Types .

  • If you want to create the database tables in a different schema than the system one, you have to follow the steps described in the relevant database product documentation.

If your database model is not completely defined, you have to specify the generated entities object-relational mapping additionally.

Note

In order that the JPA implementation handles database foreign key constraints properly, you have to configure the foreign key handling strategy in the persistence.xml explicitly.

For more information, see persistence.xml .

Prerequisites

You have created a project (for example, JPA, EJB, or Dynamic Web) to store your entities, and associated it with Java Dictionary or with a custom database schema.

Procedure

1. Create the Database Tables

  • Create the database tables in Java Dictionary.

    More information: Creating Tables

  • Create the database tables in a custom database.

    For a description of the tools and procedures, refer to the corresponding database product documentation.

    For more information about creating database tables in SAP MaxDB, see Creating Your Own Application Tables in the Database .

    Note

    You can also create your database tables using the SQL Development Tools of the Developer Studio. For more information, refer to the “Data Tools Platform User Guide” , provided by the Developer Studio help content.

2. Generate Entities from the Database Tables

  1. In the Project Explorer , select the project where you want to store the entities to be generated.

  2. In the context menu, choose Start of the navigation path JPA Tools Next navigation step Generate Entities from Tables End of the navigation path.

  3. Specify the Connection and the Schema of the data source.

    • To create a new connection, choose the Add connections pushbutton.

    • To reactivate a selected connection, choose the Connect.pushbutton.

  4. Select the tables to be used for entity generation.

  5. Optionally, define associations between the tables to be used for entity generation.

  6. To perform backward mapping immediately, choose Finish .

    If you want to customize the default settings of the generator for future usage, or if you want to configure the generator per each selected table, choose Next .

  7. (Optional) Customize the default entity generation settings, then choose Next .

  8. (Optional) Specify the entity generation settings per table.

  9. Choose Finish .

For more information about the backward mapping tools, refer to the “Dali Java Persistence Tools User Guide” , provided by the Developer Studio help content.

3. Complete the Object-Relational Mapping of the Generated Entities

For more information about the object-relational mapping tools, refer to the “Dali Java Persistence Tools User Guide” , provided by the Developer Studio help content.