
This procedure describes how to create entities manually and use the automatic generation of database tables function (also called “forward mapping” ) which is provided by SAP NetWeaver Developer Studio.
The generation of database tables from entities depends on how the object-relational mapping of the entities is organized. The object-relational mapping process includes mapping the entity to a table, specifying an entity field as a primary key, associating entity fields to table columns, defining entities' relationships, inheritance, and so on.
Once you have mapped the entity to the relational database, you can use either Java Dictionary or a custom database schema for the generation of database tables from entities.
If you are using Java Dictionary for the forward mapping, you have to consider the following requirements when specifying the object-relational mapping:
The table names must be in upper case.
A prefix of the table name is required, for example, TMP_EMPLOYEE .
The table names' length must not exceed 18 characters.
The forward mapping does not create foreign key constraints on the database.
You have created a project (for example, JPA, EJB, or Dynamic Web) to store the entities, and associated it to a Java Dictionary connection or to a database connection.
1. Create the Entities
Choose the
pushbutton.
Select , then choose Next .
Specify the required details of the entity class, then choose Next .
Specify the properties of the entity.
The data type of the entity primary key must be one of the following:
A primitive Java type
A primitive wrapper type
java.lang.String
java.util.Date
java.sql.Date
To create a composite primary key, add the primary key fields and select their Key checkboxes. The composite primary key class is generated together with the entity.
Choose Finish .
2. Specify the Object-Relational Mapping of the 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.
Instead of specifying the entities' primary keys explicitly, you can also have them generated automatically.
For more information, see Generated Primary Keys .
3. Generate Tables from the Entities
To perform forward mapping, you must have specified the object-relational mapping of your entities.
In the Project Explorer , select the project that contains your entities.
In the context menu, choose .
If your project is associated with a Java Dictionary connection profile, the table generation is completed with this step.
Fill out the required data:
Project - the project that contains the entities used for table generation
File - the name of the DDL script file to be created
Generate - additional properties to be used for the table generation
Choose Next , then choose Finish .
The Developer Studio generates and opens the DDL script file in the standard SQL editor.
If necessary, specify the details of the database connection you are using:
Type of the connection profile
Name of the connection profile
Database - the name of the database
In the context menu of the DDL script, choose Execute All .
The actual forward mapping is completed.
To see the generated tables under the relevant database node in the Data Source Explorer , you have to refresh the database and perform a clean build of the project that contains the entities.
To refresh the database in the Data Source Explorer , choose Refresh in the context menu.
To perform a clean build of the project, choose in the main menu, then choose OK .