112 Primary interfaces and classes Object getObjectById(Object id)
Wednesday, October 25th, 2006Extent 113 manager, to actually read instances from the database. Only when an Iterator is obtained and its next() method invoked does the data retrieval process commence. Therefore it is quite legitimate to obtain a particular extent at the beginning of an application, and use it to obtain Iterators as required, and in different transactions, until the application is closed. Of course, if you take this approach you should be doubly sure to close each Iterator as soon as you ve finished with it in order to conserve system resources. These Iterators are closed through the close() methods of the Extent. Extent of an interface In some implementations, it may be possible to obtain the extent of an interface. This may require the interface to have been enhanced. Iterators obtained from such an extent would yield all of the persistent JDO instances that implement the chosen interface. In theory, the extent of the SellableItem interface could be used to list items that can be placed on an order. However, this is not quite as useful as it might seem. Since interfaces have only methods and not true attributes, there can be no concept of the persistent fields of an interface. The JDO Query Language (JDOQL) requires that persistent fields be supported within query filters; arbitrary method invocations are not supported. Thus it may be impossible to execute meaningful JDOQL queries against such extents in a portable manner. For more information about JDOQL, see Chapter 8. Support for the extent of an interface should be considered non-standard unless it is explicitly included in a future version of JDO. We have already used extents in several examples when iterating through all persistent instances of a candidate class. However, the primary purpose of an extent is to provide a candidate collection of instances to a query. The query will then apply its filtering semantics to the extent. The result of query execution is a collection that is a subset of the extent containing only those instances that match the specified filter criteria. How do queries actually use extents? Although, logically, a query applies a filter to an extent, it is not expected to do this merely by iterating from start to finish. In most cases, information from the extent will merely be used to create an equivalent query in the data store s native query language. Implementations will compete amongst each other in an effort to provide the most efficient query resolution possible, by maximizing the capabilities of the underlying data store in this regard. We discuss JDOQL and the Query interface in detail in Chapter 8.
Hint: This post is supported by Gama hrvatski web hosting services