Entity > Database Export (Create tables)
- Under Project Management > Entities click onCreate tables from JPA entities.Â
- Under Persistence Unit, select the desired data source.
- 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.
- Input a name in the DDL File field, e.g. Create_CarsDB.ddl.
- 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
- Input a name in the DDL File field, e.g. Update_CarsDB.ddl.
- Under Options, select the Update Schema option.
- 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
- Establish a connection to a data source.
- In Project Management > Resources, click on the name of the DDL file you want to run.
- In the SQL editor, use the Type, Name, and Database drop-down menus to select the data source on which you want to run the DDL script.
- 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.