Entity > Database Export (Create tables)

  1. Under Project Management > Entities click onCreate tables from JPA entities
  2. Under Persistence Unit, select the desired data source.
  3. In the following wizard, select the resources folder.

Generate complete database (Create table)

Application case:
  • No database exists yet.
  • The database should be first deployed on a new test or production system.
  1. Input a name in the DDL File field, e.g. Create_CarsDB.ddl.
  2. Click Finish.


Result:
  • Create Table Statements - Generates Create Table statements for all the entities.
Parameter:
  • Export to Database - Immediately exports the generated statements.

Execute only individual changes (update)

Application case:
  • Updating an existing database.
  • Making changes to the data model and database during the development.
  • Delivering a database update
  1. Input a name in the DDL File field, e.g. Update_CarsDB.ddl.
  2. Under Options, select the Update Schema option.
  3. Click on Finish.
Result:
  • Update Statements - Generates the corresponding statements only for the changes and enhancements made.
Parameter:
  • Export to Database - Immediately exports the generated statements. 

Run DDL scripts

  1. Establish a connection to a data source.
  2. In Project Management > Resources, click on the name of the DDL file you want to run.
  3. In the SQL editor, use the TypeName, and Database drop-down menus to select the data source on which you want to run the DDL script.
  4. Right-click in the SQL editor and select context menu > Execute All.

Tips:

  • Manually generate and update database - It is helpful to manage the DDL files for all the database changes in a versioned manner. Example:
  • Automatically generate and update database - When you initially start your application in the servlet container, the database can be deployed or updated automatically. To achieve this, you must only change the validate parameter in the persistence.xml in the row below.

    <property name="hibernate.hbm2ddl.auto" value="validate" />

    Parameter:

    • validate - Standard value. The database schema is checked only. No changes are made to the database itself.
    • update - The database is updated in accordance with the changes made to the entities. Only changes and enhancements are made in the database.
    • create - The database is completely deployed. Thereby, all existing tables and data are deleted.
    • create-drop - The database is completely deployed and is, again, completely deleted after ending the session. This strategy is suitable for automated software tests, for example.

XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.