O'Reilly logo

Java Data Objects by Craig Russell, David Jordan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extent Access

An extent provides you with access to all the persistent instances of a class and, optionally, its subclasses. You can iterate over the elements of the extent or perform a query on the extent. The JDO Extent interface represents the extent of a class. Later in this chapter, we will discuss the IgnoreCache flag, which controls whether instances made persistent or deleted during the current transaction are contained in the extent.

You control whether an extent is maintained for a class in the metadata. You use the metadata class element’s requires-extent attribute to indicate whether the persistent class has an extent. It has a default value of "true“.

If your application does not need to iterate over the instances of a class or perform a query on the extent, you can set the requires-extent attribute to "false" explicitly. Even if a class does not have an extent, you can still make instances persistent, establish references to them, and navigate to them in your application and queries.

JDO 1.0.1 requires that if a class has a requires-extent set to "true“, none of its subclasses can set requires-extent to "false“. If your application specifies the subclass’s parameter to be true when calling the getExtent( ) method for a base class, all subclass instances are included in the iteration of the extent.

Accessing an Extent

You access the Extent associated with a class by calling the following PersistenceManager method:

Extent getExtent(Class persistentClass, boolean subclasses); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required