Chapter 10. Extent

An Extent is a logical view of all persistent instances of a given persistence-capable class, possibly including subclasses. Extents are obtained from PersistenceManagers, and are usually used to specify the candidate objects to a Query.

public Class getCandidateClass ();
public boolean hasSubclasses ();

The getCandidateClass method returns the persistence-capable class of the Extent's instances. The hasSubclasses method indicates whether instances of subclasses are also included.

public Iterator iterator ();
public void close (Iterator itr);
public void closeAll ();

You can obtain an iterator over every object in an Extent using the iterator method. The iterators used by some implementations might consume data store resources; therefore, you should always close an Extent's iterators as soon as you are done with them. You can close an individual iterator by passing it to the close method, or you can close all open iterators at once with closeAll.


In its default configuration, Kodo JDO automatically uses scrollable JDBC ResultSets when large data sets are being iterated. Combined with Kodo JDO's memory-sensitive data structures, this allows you to efficiently iterate over huge data sets -- even when the entire data set could not possibly fit into memory at once. These scrollable results consume database resources, however, so you are strongly encouraged to close your iterators when you are through with them. If they are not closed immediately, they will be closed when they are garbage collected by the JVM.

Example 10.1. Iterating an Extent

PersistenceManager pm = ...;

Extent employees = pm.getExtent (Employee.class, true);
Iterator itr = employees.iterator ();
    while (itr.hasNext ())
        processEmployee ((Employee) ());
    employees.close (itr);