Skip to main content

Database Initialization

Setting up your project​

To get started, you have to add the SQL expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. as an expansion resourceExpansion Resource (ExpansionResource). A reusable resource bundle containing expanders and features that provide specific application capabilities, defined in the expansion settings and added to the classpath during expansion. to your applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution. project. This can be done either in the µRadiant, or directly in the expansion settingsExpansion Settings (ExpansionSettings). The core XML configuration file specifying model locations, target expansion output directories, and expansion resources. file.

µRadiant​

  1. Open the model for your JEE application.
  2. Go the to settings tab.
  3. Add a new expansion resource with name net.democritus:sql-expanders and version 5.2.0.

Project files​

  1. Open the expansion settings file for your application, which is often found in the conf folder in the root of your project's workspace with the name expansionSettings.xml.
  2. Add a child element to expansionResources as follows:
    <expansionResource name="net.democritus:sql-expanders" version="5.2.0"/>

Generating scripts​

Generating SQL scripts with the SQL ExpandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. is as simple as adding the expansion resourceExpansion Resource (ExpansionResource). A reusable resource bundle containing expanders and features that provide specific application capabilities, defined in the expansion settings and added to the classpath during expansion.. It will automatically generate a script to generate a file to provision an SQL schema structure with the correct database dialect based on the settings of your ApplicationInstance model.

Aside from purely generating the SQL scheme to store your data, it will also attempt to provision the needed infrastructure for your persistence framework depending on which you have selected in your ApplicationInstance model. At this time, infrastructure for several methods of id generation in both Hibernate and OpenJPA are supported.

Scripts to provision the database schema(s) will be generated as [APPLICATION_ROOT]/database/001-app-database.sql.

Option
sql.structureFile.name ApplicationApplicationInstance

This option can be used to defined the name of the initial database structure script that is generated by the expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact.. The name should not include the extension, as this is added by the expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. themselves.

<options>
<sql.structureFile.name>000-init-database</sql.structureFile.name>
</options>
<options>
<sql.structureFile.name>V1__initial_table_structure</sql.structureFile.name>
</options>
Option
excludeFromSqlGeneration Component

Entire components can easily be excluded from SQL script generation by adding this option. All components that do not have this option set, will be included in the SQL scripts.

<options>
<excludeFromSqlGeneration/>
</options>

Initial data provisioning​

It is possible to generate a script with initial data for a clean deployment. The SQL ExpandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. provide an XML representation for the data represented by DataElements that is database-technology agnostic.

More in-depth information can be found on the dedicated page.