---
title: "java data jdo"
author: "mmdev"
date: "2007-11-26T20:50:00Z"
tags: []
slug: "java-data-jdo"
draft: false
lastmod: "2012-03-28T22:21:11Z"
id: 1467814
url: "https://mmdev.iteye.com/blog/1467814"
---

[![Java Data Objects (JDO)](http://db.apache.org/jdo/images/JDOx120.gif)](http://db.apache.org/jdo)[![Java Data Objects (JDO)](http://db.apache.org/jdo/images/jdo_text.gif)](http://db.apache.org/jdo)

* * *

* * *

##### General

- [Home](http://db.apache.org/jdo/index.html)
- [Why JDO?](http://db.apache.org/jdo/why_jdo.html)
- [JDO v JPA](http://db.apache.org/jdo/jdo_v_jpa.html)
- [JDO v JPA : API](http://db.apache.org/jdo/jdo_v_jpa_api.html)
- [JDO v JPA : ORM](http://db.apache.org/jdo/jdo_v_jpa_orm.html)
- [Downloads](http://db.apache.org/jdo/downloads.html)
- [License](http://www.apache.org/licenses/LICENSE-2.0 "External Link")

##### JDO Implementation

- [Specifications](http://db.apache.org/jdo/specifications.html)
- [TCK](http://db.apache.org/jdo/tck.html)

##### JDO Usage

- [Implementations](http://db.apache.org/jdo/impls.html)
- [API Javadoc](http://db.apache.org/jdo/javadoc.html)
- [Types of Classes](http://db.apache.org/jdo/class_types.html)
- [Types of Fields](http://db.apache.org/jdo/field_types.html)
- [**MetaData**](http://db.apache.org/jdo/metadata.html)
  
  - [jdo DTD/XSD](http://db.apache.org/jdo/jdo_dtd.html)
  - [orm DTD/XSD](http://db.apache.org/jdo/orm_dtd.html)
  - [jdoquery DTD/XSD](http://db.apache.org/jdo/jdoquery_dtd.html)
- [Bytecode Enhancement](http://db.apache.org/jdo/enhancement.html)
- [JDOHelper](http://db.apache.org/jdo/jdohelper.html)
- [PersistenceManagerFactory](http://db.apache.org/jdo/pmf.html)
- [PersistenceManager](http://db.apache.org/jdo/pm.html)
- [Transactions](http://db.apache.org/jdo/transactions.html)
- [Object States](http://db.apache.org/jdo/state_transition.html)
- [Object Retrieval](http://db.apache.org/jdo/object_retrieval.html)
- [Extents](http://db.apache.org/jdo/extents.html)
- [Guides](http://db.apache.org/jdo/guides.html)
- [References](http://db.apache.org/jdo/references.html)
- [Exceptions](http://db.apache.org/jdo/exceptions.html)
- [Glossary](http://db.apache.org/jdo/glossary.html)

##### Community

- [Get Involved](http://db.apache.org/jdo/get-involved.html)
- [Project Team](http://db.apache.org/jdo/team-list.html)
- [Mailing Lists](http://db.apache.org/jdo/mail-lists.html)
- [FAQ](http://db.apache.org/jdo/faq.html)
- [Wiki](http://wiki.apache.org/jdo "External Link")

##### Development

- [RoadMap / TODO](http://db.apache.org/jdo/roadmap.html)
- [Source Code](http://db.apache.org/jdo/svn.html)
- [Coding Standards](http://cwiki.apache.org/GMOxDEV/coding-standards.html "External Link")
- [Issue Tracking](http://db.apache.org/jdo/issuetracking.html)
- [Dependencies](http://db.apache.org/jdo/dependencies.html)

[]()

## Persistence MetaData

JDO 1.0 and JDO 2.0 support specification of persistence using XML MetaData. JDO 2.1 adds on the ability to specify persistence using Java5 annotations.

[]()

### XML MetaData

JDO (1.0.1, 2.0, 2.1) expects any XML MetaData to be specified in a file or files in particular positions in the file system. For example, if you have a class *com.mycompany.sample.MyExample*, JDO will look for any of the following files until it finds one (in the order stated) :-

```
META-INF/package.jdo
WEB-INF/package.jdo
package.jdo
com/package.jdo
com/mycompany/package.jdo
com/mycompany/sample/package.jdo
com/mycompany/sample/MyExample.jdo
```

In addition to specifying XML MetaData in a **jdo** file, if defining O/R mapping information you can also split this out into an ORM file. The locations for ORM files are similar in nature to those for JDO files.

```
META-INF/package-{mapping}.orm
WEB-INF/package-{mapping}.orm
package-{mapping}.orm
com/package-{mapping}.orm
com/mycompany/package-{mapping}.orm
com/mycompany/sample/package-{mapping}.orm
com/mycompany/sample/MyExample-{mapping}.orm
```

where *{mapping}* is a property specified by the user and may be "mysql" for ORM information for MySQL datastores, and "oracle" for ORM information for Oracle datastores, and so on.

[]()

### Annotations

JDO 2.1 provides support for annotations. Classes and fields/properties can be annotated defining the persistence and, optionally, any ORM information.

* * *

![](http://db.apache.org/jdo/images/header_line.gif)

[Be an Apache Software Foundation sponsor](http://www.apache.org/foundation/sponsorship.html)  
[Thanks to ASF sponsors!](http://www.apache.org/foundation/thanks.html)

Documentation published: 06 November 2007

© 2005-2007 [Apache Software Foundation](http://www.apache.org/)