3.6. Reading an Object

After an instance has been made persistent and its fields stored in the datastore, it can be retrieved again, either within the same application or by a different application.

There are three primary ways of finding an instance in the datastore with JDO—by navigation, via an Extent, or by a Query.

3.6.1. Reading by navigation

Retrieving an instance by navigation is simple. Extending the previous example, this code snippet taken from ReadByNavigationExample.java shows how the Author instance can be retrieved again in the next transaction simply by using it:


String name = author.getName();

System.out.println("Author's name is '" + name + "'.");


Underneath the covers, the JDO implementation retrieves ...

Get Core Java™ Data Objects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.