Skip Headers
Dali Java Persistence Tools User Guide
Release 3.2
Release 3.2
  PDF
PDF
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Generating entities from tables
 
Next
Generating dynamic entities from tables
 

Generating tables from entities

When using a vendor-specific platform, you can create a DDL script from your persistent entities.


Note:

The DDL script will DROP existing tables on the database and CREATE new tables, based on the entities in your project.


To generate a DDL script:

  1. Right-click the JPA project in the Project Explorer and select JPA Tools > Generate Tables from Entities.

    JPA Tools > Generate Tables from Entities
  2. On the Schema Generation page, select the generation output mode.

    Figure 3-67 Schema Generation


  3. Click Finish. Dali generates the selected DDL for the entities, as shown in Example 3-3.

If you are not currently connected to the database, the Database Connection page appears. Select your database connection and schema, and click Reconnect.

Example 3-3 Sample Generated Output

[EL Config]: metadata: The access type for the persistent class [class quickstart.demo.model.Address] is set to [FIELD].
[EL Config]: metadata: The alias name for the entity class [class quickstart.demo.model.Address] is being defaulted to: Address.
[EL Config]: metadata: The table name for entity [class quickstart.demo.model.Address] is being defaulted to: ADDRESS.
[EL Config]: metadata: The column name for element [street] is being defaulted to: STREET.
[EL Config]: metadata: The column name for element [city] is being defaulted to: CITY.
[EL Config]: metadata: The column name for element [country] is being defaulted to: COUNTRY.
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.4.0.vXXXX
[EL Fine]: connection: Detected database platform: org.eclipse.persistence.platform.database.JavaDBPlatform
[EL Config]: connection: Connection(7896086)--connecting(DatabaseLogin(
    platform=>JavaDBPlatform
    user name=> ""
    datasource URL=> "jdbc:derby:C:\MyDB;create=true"
))
[EL Config]: connection: Connection(28523022)--Connected: jdbc:derby:C:\MyDB
    User: APP
    Database: Apache Derby  Version: 10.9.1.0 - (XXXX)
    Driver: Apache Derby Embedded JDBC Driver  Version: 10.9.1.0 - (XXXX)
[EL Config]: connection: Connection(27817788)--connecting(DatabaseLogin(
    platform=>JavaDBPlatform
    user name=> ""
    datasource URL=> "jdbc:derby:C:\MyDB;create=true"
))
[EL Config]: connection: Connection(11557581)--Connected: jdbc:derby:C:\MyDB
    User: APP
    Database: Apache Derby  Version: 10.9.1.0 - (XXXX)
    Driver: Apache Derby Embedded JDBC Driver  Version: 10.9.1.0 - (XXXX)
[EL Info]: connection: file:/C:/workspace/runtime-EclipseApplication/QuickStart/build/classes/_QuickStart_url=jdbc:derby:C:\MyDB;create=true login successful
[EL Fine]: sql: Connection(28523022)--DROP TABLE ADDRESS
[EL Fine]: sql: Connection(28523022)--CREATE TABLE ADDRESS (ADDRESS_ID BIGINT NOT NULL, CITY VARCHAR(255), COUNTRY VARCHAR(255), P_CODE VARCHAR(255), PROVINCE VARCHAR(255), STREET VARCHAR(255), PRIMARY KEY (ADDRESS_ID))
[EL Config]: connection: Connection(28523022)--disconnect
[EL Info]: connection: file:/C://workspace/runtime-EclipseApplication/QuickStart/build/classes/_QuickStart_url=jdbc:derby:C:\MyDB;create=true logout successful
[EL Config]: connection: Connection(7896086)--disconnect
[EL Config]: connection: Connection(11557581)--disconnect

Related tasks

Related reference