Show TOC Start of Content Area

Procedure documentation Creating Database Tables and Generating Entities  Locate the document in its SAP Library 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 the Java Dictionary.

More information about Java Dictionary: 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.

Caution

The SAP implementation of JPA expects that there are no foreign key constraints on the database. If foreign key constraints exist, the behavior is undefined.

Prerequisites

You have:

      Opened the JPA Development perspective

      Connected your project to the Java Dictionary or to the physical database

More information:

Creating Connections to the Java Dictionary

Creating Database Connections

Procedure

...

       1.      Create the database tables.

       Create the database tables in the Java Dictionary.

More information: Creating Tables

       Create the database tables in a native database.

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

More information about creating database tables in SAP MaxDB: Creating Your Own Application Tables in the Database

Note

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

       2.      Generate entities from the database tables.

                            a.      In the Package Explorer, select the project you use for development of the entities.

                            b.      In the context menu, choose JPA Tools Generate Entities.

                            c.      Select a Connection and a Schema.

       If you want to create a new connection, choose Add connections.

More information:

Creating Connections to the Java Dictionary

Creating Database Connections

       To reactivate the selected connection, choose Reconnect.

                            d.      Choose Next.

                            e.      Complete the Source Folder and Package fields.

       Source Folder – the folder to contain the Java source files

       Package – an arbitrary name of the package to contain the entities.

                              f.      (Optional) To add the entity classes to the persistence unit, set the Synchronize Classes in persistence.xml indicator.

                            g.      Select the tables that you want to generate entities from, then choose Finish.

       3.       (Optional) Complete the object/relational mapping of the generated entities.

For more information about defining object/relational mapping, refer to the Dali Java Persistence Tools User Guide, provided by the SAP NetWeaver Developer Studio help content.

More information:

Relationships

Inheritance

Cascading Entity Manager Operations

End of Content Area