Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Developer's Guide

- Previous: Supported Data Types
- Next: Schema Capture

## Generation Options

Deployment descriptor elements or `asadmin` command line options can control automatic schema generation by:

- Creating tables during deployment

- Dropping tables during undeployment

- Dropping and creating tables during redeployment

- Specifying the database vendor

- Specifying that table names are unique

- Specifying type mappings for individual CMP fields

Note –

Before using these options, make sure you have a properly configured CMP resource. See Configuring the CMP Resource.

You can also use the deploytool to perform automatic mapping. For more information about using the deploytool, see the “Create Database Mapping” topic in the deploytool’s online help.

For a read-only bean, do not create the database schema during deployment. Instead, work with your database administrator to populate the data into the tables. See Using Read-Only Beans.

Automatic schema generation is not supported for beans with version column consistency checking. Instead, work with your database administrator to create the schema and add the required triggers. See Version Column Consistency Checking.

The following optional data subelements of the `cmp-resource` element in the `sun-ejb-jar.xml` file control the automatic creation of database tables at deployment. For more information about the `cmp-resource` element, see cmp-resource and Configuring the CMP Resource.

Table 7–3 `sun-ejb-jar.xml` Generation Elements

Element | Default | Description
--- | --- | ---
create-tables-at-deploy | `false` | If `true`, causes database tables to be created for beans that are automatically mapped by the EJB container. If `false`, does not create tables.
drop-tables-at-undeploy | `false` | If `true`, causes database tables that were automatically created when the bean(s) were last deployed to be dropped when the bean(s) are undeployed. If `false`, does not drop tables.
database-vendor-name | none | Specifies the name of the database vendor for which tables are created. Allowed values are `db2`, `mssql`, `oracle`, `pointbase`, and `sybase`, case-insensitive. If no value is specified, a connection is made to the resource specified by the `jndi-name` subelement of the `cmp-resource` element in the `sun-ejb-jar.xml` file, and the database vendor name is read. If the connection cannot be established, or if the value is not recognized, SQL-92 compliance is presumed.
schema-generator-properties | none | Specifies field-specific column attributes in `property` subelements. Each property name is of the following format: bean-name`.`field-name`.`attribute For example:
    Employee.firstName.jdbc-type
Column attributes are described in Table A–98. Also allows you to set the `use-unique-table-names` property. If `true`, this property specifies that generated table names are unique within each application server domain. The default is `false`. For further information and an example, see schema-generator-properties.

The following options of the `asadmin deploy` or `asadmin deploydir` command control the automatic creation of database tables at deployment:

Table 7–4 `asadmin deploy` and `asadmin deploydir` Generation Options

Option | Default | Description
--- | --- | ---
`--createtables` | none | If `true`, causes database tables to be created for beans that need them. If `false`, does not create tables. If not specified, the value of the `create-tables-at-deploy` attribute in `sun-ejb-jar.xml` is used.
`--dropandcreatetables` | none | If `true`, and if tables were automatically created when this application was last deployed, tables from the earlier deployment are dropped and fresh ones are created. If `true`, and if tables were not automatically created when this application was last deployed, no attempt is made to drop any tables. If tables with the same names as those that would have been automatically created are found, the deployment proceeds, but a warning indicates that tables could not be created. If `false`, settings of `create-tables-at-deploy` or `drop-tables-at-undeploy` in the `sun-ejb-jar.xml` file are overridden.
`--uniquetablenames` | none | If `true`, specifies that table names are unique within each application server domain. If not specified, the value of the `use-unique-table-names` property in `sun-ejb-jar.xml` is used.
`--dbvendorname` | none | Specifies the name of the database vendor for which tables are created. Allowed values are `db2`, `mssql`, `oracle`, `pointbase`, and `sybase`, case-insensitive. If not specified, the value of the `database-vendor-name` attribute in `sun-ejb-jar.xml` is used. If no value is specified, a connection is made to the resource specified by the `jndi-name` subelement of the `cmp-resource` element in the `sun-ejb-jar.xml` file, and the database vendor name is read. If the connection cannot be established, or if the value is not recognized, SQL-92 compliance is presumed.

If one or more of the beans in the module are manually mapped and you use any of the `asadmin deploy` or `asadmin deploydir` options, the deployment is not harmed in any way, but the options have no effect, and a warning is written to the server log.

If the deploytool mapped one or more of the beans, the `--uniquetablenames` option of `asadmin deploy` or `asadmin deploydir` has no effect. The uniqueness of the table names was established when deploytool created the mapping.

The following options of the `asadmin undeploy` command control the automatic removal of database tables at undeployment:

Table 7–5 `asadmin undeploy` Generation Options

Option | Default | Description
--- | --- | ---
`--droptables` | none | If `true`, causes database tables that were automatically created when the bean(s) were last deployed to be dropped when the bean(s) are undeployed. If `false`, does not drop tables. If not specified, the value of the `drop-tables-at-undeploy` attribute in `sun-ejb-jar.xml` is used.

For more information about the `asadmin deploy`, `asadmin deploydir`, and `asadmin undeploy` commands, see the Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Reference Manual.

When command line and `sun-ejb-jar.xml` options are both specified, the `asadmin` options take precedence.

- Previous: Supported Data Types
- Next: Schema Capture

- © 2010, Oracle Corporation and/or its affiliates