diff --git a/openjpa-project/src/doc/manual/ref_guide_remote.xml b/openjpa-project/src/doc/manual/ref_guide_remote.xml index 9d7bc8c00..09d35eb54 100644 --- a/openjpa-project/src/doc/manual/ref_guide_remote.xml +++ b/openjpa-project/src/doc/manual/ref_guide_remote.xml @@ -224,89 +224,103 @@ When detached objects lose their association with the OpenJPA runtime, they also lose the ability to load additional state from the datastore. It is important, therefore, to populate objects with all the persistent state you will need before detaching them. While you are free to do this manually, OpenJPA includes -facilities for automatically populating objects when they detach. The -openjpa.DetachState +facilities for automatically populating objects when they detach. + +
+ + Detached State + + + + detachment + + + detached state + + + +The openjpa.DetachState configuration property determines which fields and relations are detached by default. All settings are recursive. They are: - - - - + + + + loaded: Detach all fields and relations that are already loaded, but don't include unloaded fields in the detached graph. This is the default. - - - - + + + + fetch-groups: Detach all fields and relations in the current fetch configuration. For more information on custom fetch groups, see . - - - - + + + + all: Detach all fields and relations. Be very careful when using this mode; if you have a highly-connected domain model, you could end up bringing every object in the database into memory! - - - - + + + + Any field that is not included in the set determined by the detach mode is set to its Java default value in the detached instance. - - + + The openjpa.DetachState option is actually a plugin string (see ) that allows you to also configure the following options related to detached state: - - - - + + + + DetachedStateField: As described in above, OpenJPA can take advantage of a detached state field to make the attach process more efficient. This field is added by the enhancer and is not visible to your application. Set this property to one of the following values: - - - - + + + + transient: Use a transient detached state field. This gives the benefits of a detached state field to local objects that are never serialized, but retains serialization compatibility for client tiers without access to the enhanced versions of your classes. This is the default. - - - - + + + + true: Use a non-transient detached state field so that objects crossing serialization barriers can still be attached efficiently. This requires, however, that your client tier have the enhanced versions of your classes and the OpenJPA libraries. - - - - + + + + false: Do not use a detached state field. - - - - + + + + You can override the setting of this property or declare your own detached state field on individual classes using OpenJPA's metadata extensions. See below. - - - - + + + + DetachedStateManager: Whether to use a detached state manager. A detached state manager makes attachment much more efficient. Like a detached state field, however, it breaks serialization compatibility with the unenhanced class if it isn't transient. - - + + This setting piggybacks on the DetachedStateField setting above. If your detached state field is transient, the detached state manager will also be transient. If the detached state field is disabled, the detached @@ -317,18 +331,18 @@ setting this property to false, however, you can use a detached state field may be useful for debugging or for legacy OpenJPA users who find differences between OpenJPA's behavior with a detached state manager and OpenJPA's older behavior without one. - - - - + + + + AccessUnloaded: Whether to allow access to unloaded fields of detached objects. Defaults to true. Set to false to throw an exception whenever an unloaded field is accessed. This option is only available when you use detached state managers, as determined by the settings above. - - - - + + + + LiteAutoDetach: This option is ONLY valid for the loaded DetachState setting. Detach all fields and relations as described by the loaded property when an explicit detach is requested or when a @@ -338,43 +352,43 @@ the minimal amount of work will be completed to disassociate all Entities from the persistence context. It is highly recommended that all Entities have a @Version field when using this property. In addition, care needs to be taken when this value is set to true as the following caveats apply: - - - + + + A relationship from a managed Entity to an unmanaged Entity which was detached by the lite detach setting will not be persisted. - - - - + + + + When merging a detached Entity back into the persistence context any lazily loaded fields that were marked to null when detached will not be persisted. - - - - - - - - - Configuring Detached State - + + + + + + + + + Configuring Detached State + <property name="openjpa.DetachState" value="fetch-groups(DetachedStateField=true)"/> - - + + You can also alter the set of fields that will be included in the detached graph at runtime. OpenJPAEntityManagers expose the following APIs for controlling detached state: - + public DetachStateType getDetachState(); public void setDetachState(DetachStateType type); - + The DetachStateType enum contains the following values: - + enum DetachStateType { FETCH_GROUPS, @@ -382,6 +396,7 @@ enum DetachStateType { ALL } +
Detached State Field