Skip Headers

# Default Mapping in CMP Projects Using OC4J at Run Time

Previous

Next

Default mapping is a relational persistence framework term that refers to making the framework automatically generate the object descriptor metadata (including such things as mappings, login data, database platform, locking, and foreign keys).

Note: You can apply default mapping to relational projects only.

TopLink can also optionally create or drop-and-create the tables associated with the entities during the deployment. This means that TopLink can handle the whole deployment process with the minimum requirements: a compliant EAR file and a valid data source. This frees you from creating tables and specifying mappings before you deploy your application.

TopLink default mapping supports the following features:

- Direct-to-field mapping support for standard CMP (that is, not dependent object) fields.

- Serialized object mapping support for dependent objects.

- One-to-one, one-to-many, and many-to-many mappings support for CMR fields.

- Self-referencing, unidirectional and bidirectional relationship mappings (see "Directionality").

- Optimistic version locking for each entity.

- Automatic table drop and create, platform-specified supported types, default size and subsize, and database-reserved keywords.

- EJB QL (EJB query language) queries, such as finder and ejbSelect.

- Unknown primary key class case (primary key-class type `java.lang.Object.class`).

Default mapping is available for CMP relational projects deployed to OC4J configured to use TopLink as the default persistence manager. In this configuration, the EJB container provides the entity bean descriptor data (from `ejb-jar.xml`) required by the persistence manager to generate the persistence descriptor file.

If a `toplink-ejb-jar.xml` descriptor file is not present, TopLink, working as the OC4J default persistence manager, generates a default persistence descriptor file for any CMP project during deployment. In this case, TopLink applies default mappings and, optionally, automatic table generation. The generated descriptor file includes the following:

- Mapping for each entity CMP and CMR field

- Optimistic locking, foreign keys, target foreign key, and relation table

- Transparent indirection for relationships

- Database login and platform metadata

If a `toplink-ejb-jar.xml` descriptor file is present and specified in the `orion-ejb-jar.xml` file, TopLink does not apply default mapping: it honours the mappings specified in the `toplink-ejb-jar.xml` file. In this case, you can still configure automatic table generation.

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

Note: The preceding information is also applicable to EJB 3.0 persistent relational projects. EJB 3.0 annotations often replace descriptor files. For example, TopLink does not apply default mapping if annotations that are equivalent to `toplink-ejb-jar.xml` descriptor file are specified.