1.7. Using Externalization to Persist Second Class Objects

The files for this sample are located in the samples/externalization directory of the Kodo installation. This sample demonstrates how to persist field types that aren't directly supported by JDO using Kodo's externalization framework.

The ExternalizationFields class is a persistence-capable class with fields of various types, none of which are recognized by JDO. The JDO metadata for ExternalizationFields uses Kodo's "externalizer" and "factory" metadata extensions to name methods that can be used to transform each field into a supported type, and then reconstruct it from its external form. Even complex external forms are supported; the ExternalizationFields.pair field externalizes to a list of persistence-capable objects.

The ExternalizationFieldsMain class is a driver to demonstrate that ExternalizationFields instances persist correctly.