boolean enabled: Whether to cache data for instances of the
class. Defaults to true for base classes, or the superclass
value for subclasses. If you set this property to false, all
other properties are ignored.

int timeout: The number of milliseconds data for the class
remains valid. Use -1 for no timeout. Defaults to the
openjpa.DataCacheTimeout
property value.

3.1.3.
Detached State

The OpenJPA enhancer may add a
synthetic field to detachable classes to hold detached state (see
Section 1.3, “
Defining the Detached Object Graph
” for details). You can instead
declare your own detached state field or supress the creation of a detached
state field altogether. In the latter case, your class must not use
datastore identity, and should declare
a version field to detect optimistic concurrency errors during detached
modifications.

String fieldName: Use this property to declare your own
detached state field. The field must be of type Object.
Typically this property is only used if the field is inherited from a
non-persisted superclass. If the field is declared in your entity class, you
will typically annotate the field directly, as described below.

If you declare your own detached state field, you can annotate that field with
DetachedState directly, rather than placing the
annotation at the class level and using the fieldName
property. When placed on a field, DetachedState acts as a
marker annotation; it does not recognize any properties. Your annotated field
must be of type Object.

3.2.1.
Dependent

In a dependent relation, the referenced object is deleted
whenever the owning object is deleted, or whenever the relation is severed by
nulling or resetting the owning field. For example, if the
Magazine.coverArticle field is marked dependent, then setting
Magazine.coverArticle to a new Article
instance will automatically delete the old Article stored
in the field. Similarly, deleting a Magazine object will
automatically delete its current cover Article. (This
latter processing is analogous to using JPA's CascadeType.REMOVE functionality
as described in Section 2.8.1, “
Cascade Type
”.) You can
prevent an orphaned dependent object from being automatically deleted by
assigning it to another relation in the same transaction.

OpenJPA offers a family of marker annotations to denote dependent relations in
JPA entities:

UpdateAction.IGNORE: Updates to the field are completely
ignored. The field is not considered dirty. The new value will not even get
stored in the OpenJPA data cache.

UpdateAction.RESTRICT: Any attempt to change the field will
result in an immediate exception.

3.2.6.
Type

OpenJPA has three levels of support for relations:

Relations that hold a reference to an object of a concrete persistent class are
supported by storing the primary key values of the related instance in the
database.

Relations that hold a reference to an object of an unknown persistent class are
supported by storing the stringified identity value of the related instance.
This level of support does not allow queries across the relation.

Relations that hold an unknown object or interface. The only way to support
these relations is to serialize their value to the database. This does not allow
you to query the field, and is not very efficient.

Clearly, when you declare a field's type to be another persistence-capable
class, OpenJPA uses level 1 support. By default, OpenJPA assumes that any
interface-typed fields you declare will be implemented only by other persistent
classes, and assigns interfaces level 2 support. The exception to this rule is
the java.io.Serializable interface. If you declare a
field to be of type Serializable, OpenJPA lumps it
together with java.lang.Object fields and other
non-interface, unrecognized field types, which are all assigned level 3 support.

With OpenJPA's type family of metadata extensions, you can control the level of
support given to your unknown/interface-typed fields. Setting the value of this
extension to Entity indicates that the
field value will always be some persistent object, and gives level 2 support.
Setting the value of this extension to the class of a concrete persistent type
is even better; it gives you level 1 support (just as if you had declared your
field to be of that type in the first place). Setting this extension to
Object uses level 3 support. This is useful when you have
an interface relation that may not hold other
persistent objects (recall that OpenJPA assumes interface fields will always
hold persistent instances by default).