7.4. Mapping Defaults

The previous sections showed how to use the mapping tool to generate default mappings. But how does the mapping tool know what mappings to generate? The answer lies in the kodo.jdbc.meta.MappingDefaults interface. Kodo uses an instance of this interface to decide how to name tables and columns, where to put foreign keys, and generally how to create a schema that matches your object model.


Kodo relies on foreign key constraint information at runtime to order SQL appropriately. Be sure to set your mapping defaults to reflect your existing database constraints, or use explicit foreign key mappings as described in Section, “Foreign Keys” for JPA, and Section 15.12, “Foreign Keys” of the JDO Overview .

The kodo.jdbc.MappingDefaults configuration property controls the MappingDefaults interface implementation in use. This is a plugin property (see Section 2.5, “Plugin Configuration”), so you can substitute your own implementation or configure the existing ones. Kodo includes the following standard implementations:

The example below turns on foreign key generation during schema creation and associates the org.mag.data.InfoStruct field type with the custom org.mag.mapping.InfoStructHandler value handler.

Example 7.18. Configuring Mapping Defaults

JPA XML format:

<property name="kodo.jdbc.MappingDefaults" 

JDO properties format:

kodo.jdbc.MappingDefaults: ForeignKeyDeleteAction=restrict, \


Skip navigation bar   Back to Top