Retrieval of Fields

You should not be concerned about how and when the JDO implementation accesses fields from the datastore. When you access a field, the JDO implementation provides the field’s value. But some facilities let you instruct the JDO implementation to load all or a particular subset of fields of an instance together. You can analyze your application’s field-access requirements and optimize the performance of accessing fields from the datastore.

Default Fetch Group

A fetch group is a group of fields retrieved together from the datastore. JDO implementations usually can retrieve a group of fields as a unit more efficiently than they can retrieve each field individually. In addition, you may have a specific subset of fields that your applications always use together; in this case, accessing these fields as a unit may be more efficient. Conversely, fields that are rarely accessed could be placed in a separate fetch group that is retrieved only when necessary. When fields that are not contained in any fetch group are accessed, they can be retrieved from the datastore individually.

JDO defines one fetch group, called the default fetch group (DFG). A field element’s default-fetch-group attribute specifies whether a field should be in the default fetch group. This attribute defaults to "true" for nonkey fields of the following types:

  • Primitive types

  • java.util.Date

  • Fields in the java.lang package of the types listed in Table 4-2

  • java.math.BigDecimal and java.math.BigInteger

An instance ...

Get Java Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.