In this tutorial you will become familiar with the basic tools and development processes under Kodo by creating a simple JDO application.
Imagine that you have decided to create a software toolkit to be used by pet shop operators. This toolkit must provide a number of solutions to common problems encountered at pet shops. Industry analysts indicate that the three most desired features are inventory maintenance, inventory growth simulation, and behavioral analysis. Not one to question the sage advice of experts, you choose to attack these three problems first.
According to the aforementioned experts, most pet shops focus on three types of animals only: dogs, rabbits, and snakes. This ontology suggests the following class hierarchy:
Animal ^ | +--------------------+ | | | Dog Rabbit Snake
We have provided an implementation of Animal and Dog classes, plus some helper classes and files to create the initial schema and populate the database with some sample dogs. Let's take a closer look at these classes.
tutorial.AnimalMaintenance: Provides some utility methods for examining and manipulating the animals stored in the database. We will fill in method definitions in Section 2.3, “Inventory Maintenance”.
tutorial.Animal: This is the superclass of all animals that this pet store software can handle.
tutorial.Dog : Contains data and methods specific to dogs.
tutorial.Rabbit: Contains data and methods specific to rabbits. It will be used in Section 2.4, “Inventory Growth”.
tutorial.Snake: Contains data and methods specific to snakes. It will be used in Section 2.5, “Behavioral Analysis”.
package.jdo: This is a JDO metadata file that defines which types should be enhanced into persistence-capable or persistence-aware classes. For more information on JDO metadata, consult Chapter 5, Metadata of the JDO Overview.
kodo.properties: This properties file contains Kodo-specific and standard JDO configuration settings.
You must specify a valid Kodo license key in the kodo.properties file.
solutions: The solutions directory contains the complete solutions to this tutorial, including finished versions of the .java files listed above and a correct package.jdo metadata file.
java: Runs main methods in specified Java classes.
javac: Compiles .java files into .class files that can be executed by java.
jdoc: Runs the Kodo JDO enhancer against the specified classes. More information is available in Section 5.5, “Enhancement” of the Reference Guide.
mappingtool -action refresh: A utility that can be used to create and maintain the object-relational mappings and schema of all persistent classes in a JDBC-compliant data store. This functionality allows the underlying mappings and schema to be easily kept up-to-date with the Java classes in the system. See Chapter 7, Object-Relational Mapping of the Reference Guide for more information.