5.7. Metadata Placement

JDO metadata must be available both during class enhancement and at runtime. The metadata document listing a persistent class must be available as a resource from the class' class loader, and must exist in one of two standard locations:

  1. In a resource called <class-name>.jdo, where <class-name> is the name of the class the document applies to, without package name. The resource must be located in the same package as the class.

  2. In a resource called package.jdo. The resource should be placed in the corresponding package, or in any ancestor package. Package-level documents contain the metadata for all the persistence-capable classes in the package, except those classes that have individual class-name.jdo resources. Package-level documents may also contain the metadata for classes in any sub-packages.

Assuming you are using a standard Java class loader, these rules imply that for a class Magazine defined by the file org/mag/Magazine.class, you can define the corresponding metadata in any of the following files:

Because metadata documents are loaded as resources, JDO implementations can also read them from jar files.

 

Skip navigation bar   Back to Top