|  |  |  | License Codehaus OpenEJB OpenJMS OpenORB Tyrex

Old releases
General
Release 1.3
Release 1.3rc1
Release 1.2

Main
Home
About
Features
Download
Dependencies
Reference guide
Publications
JavaDoc
Maven 2 support
Maven 2 archetypes
DTD & Schemas
Recent HTML changes
News Archive
RSS news feed
Project Wiki

Development/Support
Mailing Lists
SVN/JIRA
Contributing
Support
Continuous builds
Prof. services

Related projects
Spring ORM support
Spring XML factories
WS frameworks

XML
XML

XML Code Generator
XML Code Generator

JDO
Introduction
First steps
Using JDO
JDO Config
Types
JDO Mapping
JDO FAQ
JDO Examples
JDO HOW-TOs
Tips & Tricks
Other Features
JDO sample JAR

Tools
Schema generator

Advanced JDO
Caching
OQL
Trans. & Locks
Design
KeyGen
Long Trans.
Nested Attrs.
Pooling Examples
LOBs
Best practice

DDL Generator
Using DDL Generator
Properties
Ant task
Type Mapping

More
The Examples
3rd Party Tools
JDO Tests
XML Tests
Configuration

About
License
User stories
Contributors
Marketplace
Status, Todo
Changelog
Library
Contact
Project Name

## Castor DDL Generator - Properties

Documentation Author(s):
Ralf Joachim

Overview
Global properties
Supported database engines
Grouping of DDL statements
Specific properties
Properties common for all database engines
Key generators
Properties for db2, hsql, Oracle, Postgresql and sapdb
Trigger template
Properties for MySQL only

## Overview

At startup, the DDL Generator first evaluates the command line options. Next it loads the global properties on the command line if specified, otherwise the default properties included with the DDL Generator. There are two important properties loaded at startup:

`org.castor.ddlgen.Generators`
  tells the DDL Generator about the supported database engines.
`org.castor.ddlgen.DefaultEngine`
  The database engine for which to generate a SQL script. Can be overridden on the command line.

The last step at startup is to read the specific configuration of the database engine being used. A custom configuration can be provided on the command line to override the default.

## Global properties

Below you can find a list of global properties to control various advanced options of the DDL Generator.

Option | Description | Values | Default | Since
org.castor.ddlgen.Generators | Generator classes of supported database engines. |  |  | 1.1
org.castor.ddlgen.DefaultEngine | Name of default database engine. Will be overwritten by engine specified on commandline. | db2, derby, hsql, mssql, mysql, oracle, pointbase, postgresql, sapdb or sybase | mysql | 1.1
org.castor.ddlgen.SchemaName | Name of the database schema. |  | test | 1.1
org.castor.ddlgen.GroupStatements | How to group generated DDL statements? | TABLE or DDLTYPE | TABLE | 1.1
org.castor.ddlgen.CharFormat | How to format characters of generated DDL statements? | SENSITIVE, UPPER or LOWER | SENSITIVE | 1.1
org.castor.ddlgen.Newline | Character sequence to write for newline. |  | \n | 1.1
org.castor.ddlgen.Indention | Character sequence to write for indented lines. |  | \t | 1.1
org.castor.ddlgen.GenerateSchema | Generate SCHEMA statements. | true or false | true | 1.1
org.castor.ddlgen.GenerateDrop | Generate DROP statements. | true or false | true | 1.1
org.castor.ddlgen.GenerateCreate | Generate CREATE statements. | true or false | true | 1.1
org.castor.ddlgen.GeneratePrimaryKey | Generate PRIMARYKEY statement. | true or false | true | 1.1
org.castor.ddlgen.GenerateForeignKey | Generate FOREIGNKEY statement. | true or false | true | 1.1
org.castor.ddlgen.GenerateIndex | Generate INDEX statements (Not supported yet). | true or false | false | 1.1
org.castor.ddlgen.GenerateKeyGenerator | Generate KEYGENERATOR statements. | true or false | true | 1.1
default_tinyint_precision | Default precision of tinyint values. |  |  | 1.1
default_smallint_precision | Default precision of smallint values. |  |  | 1.1
default_integer_precision | Default precision of integer values. |  |  | 1.1
default_bigint_precision | Default precision of bigint values. |  | 19 | 1.1
default_bigint_decimals | Default decimals of bigint values. |  | 0 | 1.1
default_float_precision | Default precision of float values. |  | 38 | 1.1
| Default precision of tinyint values. |  |  | 1.1
default_float_decimals | Default decimals of float values. |  | 7 | 1.1
default_double_precision | Default precision of double values. |  | 53 | 1.1
default_double_decimals | Default decimals of double values. |  | 15 | 1.1
default_real_precision | Default precision of real values. |  | 38 | 1.1
default_real_decimals | Default decimals of real values. |  | 7 | 1.1
default_numeric_precision | Default precision of numeric values. |  | 65 | 1.1
default_numeric_decimals | Default decimals of numeric values. |  | 30 | 1.1
default_decimal_precision | Default precision of decimal values. |  | 65 | 1.1
default_decimal_decimals | Default decimals of decimal values. |  | 30 | 1.1
default_char_length | Default length of char values. |  | 256 | 1.1
default_varchar_length | Default length of varchar values. |  | 256 | 1.1
default_longvarchar_length | Default length of longvarchar values. |  | 1024 | 1.1
default_date_precision | Default precision of date values. |  |  | 1.1
default_time_precision | Default precision of time values. |  |  | 1.1
default_timestamp_precision | Default precision of timestamp values. |  | 19 | 1.1
default_binary_length | Default length of binary values. |  | 256 | 1.1
default_varbinary_length | Default length of varbinary values. |  | 256 | 1.1
default_longvarbinary_length | Default length of longvarbinary values. |  | 1024 | 1.1
default_other_length | Default length of other values. |  | 1024 | 1.1
default_javaobject_length | Default length of javaobject values. |  | 1024 | 1.1
default_blob_length | Default length of blob values. |  | 1024 | 1.1
default_clob_length | Default length of clob values. |  | 1024 | 1.1

### Supported database engines

The supported database engines are defined as follows:

    #
    # generator classes of supported database engines
    #
    org.castor.ddlgen.Generators=\
      org.castor.ddlgen.engine.db2.Db2Generator,\
      org.castor.ddlgen.engine.derby.DerbyGenerator,\
      org.castor.ddlgen.engine.hsql.HsqlGenerator,\
      org.castor.ddlgen.engine.mssql.MssqlGenerator,\
      org.castor.ddlgen.engine.mysql.MysqlGenerator,\
      org.castor.ddlgen.engine.oracle.OracleGenerator,\
      org.castor.ddlgen.engine.pointbase.PointBaseGenerator,\
      org.castor.ddlgen.engine.postgresql.PostgresqlGenerator,\
      org.castor.ddlgen.engine.sapdb.SapdbGenerator,\
      org.castor.ddlgen.engine.sybase.SybaseGenerator

### Grouping of DDL statements

There are 2 supported modes to group DDL statements. For a simple example, the output of both modes is:

org.castor.ddlgen.GroupStatements=TABLE

    drop A if exist
    create A(IDA int);
    alter table A add primary key (IDA)

    drop B if exist
    create B(IDB int);
    alter table B add primary key (IDB)

org.castor.ddlgen.GroupStatements=DDLTYPE

    drop A if exist
    drop B if exist

    create A(IDA int);
    create B(IDB int);

    alter table A add primary key (IDA)
    alter table B add primary key (IDB)

## Specific properties

Below you can find a list of specific properties to control various advanced options of the DDL Generator.

### Properties common for all database engines

Option | Description | Values | Default | Since
org.castor.ddlgen.KeyGeneratorFactories | Key generator factory classes supported by DB/2. |  |  | 1.1
org.castor.ddlgen.HeaderComment | Comment to add to head of generated script. |  |  | 1.1

#### Key generators

The key generators supported by a database engine are defined as follows (example taken from Oracle):

    #
    # key generator factory classes of supported database engines
    #
    org.castor.ddlgen.KeyGeneratorFactories=\
      org.castor.ddlgen.keygenerator.HighLowKeyGeneratorFactory,\
      org.castor.ddlgen.keygenerator.MaxKeyGeneratorFactory,\
      org.castor.ddlgen.keygenerator.UUIDKeyGeneratorFactory,\
      org.castor.ddlgen.engine.oracle.OracleSequenceKeyGeneratorFactory

### Properties for db2, hsql, Oracle, Postgresql and sapdb

Option | Description | Values | Default | Since
org.castor.ddlgen.TriggerTemplate | Template to create TRIGGER statements. |  |  | 1.1

#### Trigger template

Below you can take a look at the default trigger template defined for Oracle. The DDL Generator will replace the parameters in brackets with appropriate values (e.g. <table_name>).

    #
    # trigger template
    #
    org.castor.ddlgen.TriggerTemplate=\
    CREATE TRIGGER <trigger_name>\n\t\
      BEFORE INSERT OR UPDATE ON <table_name>\n\t\
      FOR EACH ROW\n\t\
      DECLARE\n\t\t\
        iCounter <table_name>.<pk_name>%TYPE;\n\t\t\
        cannot_change_counter EXCEPTION;\n\t\
      BEGIN\n\t\t\
        IF INSERTING THEN\n\t\t\t\
          Select <sequence_name>.NEXTVAL INTO iCounter FROM Dual;\n\t\t\t\
          :new.<pk_name> := iCounter;\n\t\t\
        END IF;\n\t\
    \n\t\t\
        IF UPDATING THEN\n\t\t\t\
          IF NOT (:new.<pk_name> = :old.<pk_name>) THEN\n\t\t\t\t\
            RAISE cannot_change_counter;\n\t\t\t\
          END IF;\n\t\t\
        END IF;\n\t\
    \n\t\
    EXCEPTION\n\t\t\
      WHEN cannot_change_counter THEN\n\t\t\t\
        raise_application_error(-20000, 'Cannot Change Counter Value');\n\t\
    END;

### Properties for MySQL only

Option | Description | Values | Default | Since
org.castor.ddlgen.engine.mysql.StorageEngine | Storage engine to be used. If left empty the default configured at the database server will be used. | MYISAM, InnoDB, MERGE, MEMORY, BDB or ISAM |  | 1.1
org.castor.ddlgen.engine.mysql.ForeignKeyOnDeleteStrategy | Delete strategy for foreign keys. If not specified NO ACTION will be used by default. | CASCADE, RESTRICT, SET NULL, NO ACTION |  | 1.1
org.castor.ddlgen.engine.mysql.ForeignKeyOnUpdateStrategy | Update strategy for foreign keys. If not specified NO ACTION will be used by default. | CASCADE, RESTRICT, SET NULL, NO ACTION |  | 1.1

<notice> Copyright © 1999-2005 ExoLab Group, Intalio Inc., and Contributors. All rights reserved. </notice>
<notice> Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners. </notice>