SQL Module

 

SQL Module

The SQL Module is responsible for writing SQL files out. The SQL writers create all the files necessary to create a database, remove date from a database and remove objects from a database. The SQL writers understand the database vendor from the Dictionary and write out the correct database code accordingly.

The SQLModule contains the following classes:-

  • com.javelin.generator.sql.SQLWriter
  • com.javelin.generator.sql.SQLKeyWriter
  • com.javelin.generator.sql.SQLDeleteDataWriter
  • com.javelin.generator.sql.SQLDropObjectsWriter

In order to use the SQL module you need to include the following writer:

$GENERATOR.AggregateWriter jdbc

Class Hierarchy

The top-level SQL Writer class hierarchy is illustrated below: -

SQL Properties

The default path name for the SQL directory containing the SQL files is the default pathName (default.pathName)

This can be overridden with following property: -

sql.pathName=<PATHNAME>

For example: -

sql.pathName=$ROOT/sql

Below this path the sql is created in a sub directory using the property sql.sqlPathName. This is defaulted to.

sqlPackage.pathName=sql

Abstract SQL Writer (com.javelin.generator.sql.AbstractSQLWriter)

 

SQL Writer (com.javelin.generator.sql.SQLWriter)

The SQL Writer is responsible for writing all the tables, indexes and views for the database.

For each vendor the SQL writer understands

  • How to switch databases.
  • How to map types.
  • How to create Primary Keys.
  • How to create Foreign Keys.
  • When to create Indexes.

 

SQL Key Writer (com.javelin.generator.sql.SQLKeyWriter)

The SQL Key Writer is responsible for writing SQL to create a Key table and populate it with the primary key seeds for all the tables.

SQL Delete Data Writer (com.javelin.generator.sql.SQLDeleteDataWriter)

The SQL Delete Data Writer is responsible for writing SQL to delete data from all the tables. The delete commands are ordered to reduce foreign key constraints from stopping the deletion.

SQL Drop Objects Writer (com.javelin.generator.sql.SQLDropObjectsWriter)

The SQL Drop Objects Writer is responsible for writing SQL to delete all the tables. The drop commands are ordered to reduce foreign key constraints from stopping the dropping.