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 JPA implementation underlying the SAPNetWeaver Application Server Java 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 table.

       Create the database table in the Java Dictionary.

More information: Creating Tables

       Creating the database table 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 MaxDB: Creating Your Own Application Tables in the Database

       2.      Generate an entity from the database table.

Note

If you want to generate several entities, you can create the corresponding tables and implement this procedure only once.

                            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.      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.

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

                            e.      Select the tables that you want to generate entities from and choose Finish.

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

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.

End of Content Area