Skip Headers

# Automatic Database Table Creation

Previous

Next

If you deploy a CMP project to OC4J configured to use TopLink as the persistence manager, then you can configure OC4J to automatically create (and, optionally, delete) database tables for your persistent objects.

You can configure automatic database table creation at one of three levels as Table: Configuring Automatic Table Generation shows. You can override the system level configuration at the application level and you can override system and application configuration at the EJB module level.

Configuring Automatic Table Generation

Level | Configuration File | Setting | Values
--- | --- | --- | ---
System (global) | `<``OC4J_HOME``>/config/application.xml` | `autocreate-tables` | `True` Foot 1 or `False`
|  | `autodelete-tables` | `True` or `False` Footref 1
Application (EAR) | `orion-application.xml` | `autocreate-tables` | `True` Footref 1 or `False`
|  | `autodelete-tables` | `True` or `False` Footref 1
EJB Module (JAR) | `orion-ejb-jar.xml` | `pm-properties` sub-element `default-mapping` attribute `db-table-gen` Foot 2 | `Create`, `DropAndCreate`, or `UseExisting` Foot 3

Footnote 1 Default.

Footnote 2 For more information, see "Configuring default-mapping Properties".

Footnote 3 See Table: Equivalent Settings for db-table-gen.

If you configure automatic table generation at the EJB module level, the value you assign to the `db-table-gen` attribute corresponds to the `autocreate-tables` and `autodelete-tables` settings as Table: Equivalent Settings for db-table-gen shows.

Equivalent Settings for db-table-gen

db-table-gen Setting | autocreate-tables Setting | autodelete-tables Setting
--- | --- | ---
`Create` | `True` | `False`
`DropAndCreate` | `True` | `True`
`UseExisting` | `False` | NA

You can use this feature in conjunction with default mapping (see "Default Mapping in CMP Projects Using OC4J at Run Time").