Chapter 3. Creating Persistent Classes
Prev | Part III. Kodo JDO Reference Guide | Next

## Chapter 3. Creating Persistent Classes

Persistent class basics are covered in the JDO Overview. This chapter details the tools Kodo JDO provides to aid in persistent class creation, and tips on how to optimize your classes for the Kodo JDO runtime.

## 3.1. Application Identity Class Generation

Kodo JDO supports both datastore and application JDO identity types. If you choose to use application identity, you may want to take advantage of Kodo JDO's `appidtool`.

The `appidtool` generates Java code implementing the object identity class for any persistent type using application identity. The code satisfies all the requirements JDO places on object identity classes. You can use it as-is, or simply use it as a starting point, editing it to meet your needs.

Before you can run the `appidtool` for a persistent class, the class must be compiled and must have JDO metadata. The metadata should include the `objectid-class`, though whatever class it refers to obviously may not exist yet. The tool will use the attribute to name the identity class that it generates.

The `appidtool` can be invoked via the included `appidtool` script or via its java class, `com.solarmetric.kodo.enhance.ApplicationIdTool`. It accepts the standard set of command-line arguments defined by the configuration framework. It also accepts an `-ignoreErrors` flag. If this flag is set to `false`, an exception will be thrown if the tool is run on any class that does not use application identity, or is not the base class in the inheritance hierarchy (subclasses never define the application identity class; they inherit it from their persistent superclass).

Each additional argument to the tool must be one of the following:

- The full name of a persistent class.

- The `.class` file of a persistent class.

- A `.jdo` metadata file. The identity class of each class listed in the metadata will be generated.

The `.java` file generated for each identity class will be placed in the same directory as the parent class' `.java` file. If the generated file is overwriting an older file, the older file will be backed up to `<file-name>~`.

| Note
The `.java` for the parent class must be in the `CLASSPATH`.

Example 3.1. Using the Application Identity Tool

There are many ways to invoke the `appidtool`.

    java com.solarmetric.kodo.enhance.ApplicationIdTool com.solarmetric.examples.Person
    java com.solarmetric.kodo.enhance.ApplicationIdTool -properties myapp.properties package.jdo
    appidtool -licenseKey xxx-yyy-zzz com/solarmetric/examples/*.jdo
    appidtool com.solarmetric.examples.Person Employee.class com/solarmetric/examples/Project.jdo

Prev | Up | Next
2.3. Logging Framework | Home | 3.2. Enhancement