Package org.apache.openjpa.kernel
Class InverseManager
java.lang.Object
org.apache.openjpa.kernel.InverseManager
- All Implemented Interfaces:
Configurable
Class which manages inverse relations before flushing
to the datastore. Ensures that inverse fields are set.
Currently limited to managing PC and Collection-type relations.
- Author:
- Steve Kim
-
Field Summary
Modifier and TypeFieldDescriptionprotected DataCacheManager
static final int
Constant representing theACTION_EXCEPTION
actionstatic final int
Constant representing theACTION_MANAGE
actionstatic final int
Constant representing theACTION_WARN
actionprotected static final Object
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToCollection
(OpenJPAStateManager sm, FieldMetaData fmd, Object val) Add the given value to the collection at the selected field.protected void
clearInverseRelations
(OpenJPAStateManager sm, Object val, FieldMetaData fmd, FieldMetaData[] inverses) Clear all inverse the relations fromval
to the instance managed bysm
.protected void
clearInverseRelations
(OpenJPAStateManager sm, FieldMetaData fmd, FieldMetaData[] inverses, Object newValue) Remove all relations between the initial value offmd
for the instance managed bysm
and its inverses.void
correctRelations
(OpenJPAStateManager sm, FieldMetaData fmd, Object value) Correct relations from the given dirty field to inverse instances.protected void
createInverseRelations
(StoreContext ctx, Object fromRef, Object toRef, FieldMetaData fmd, FieldMetaData[] inverses) Create the inverse relations for all the given inverse fields.void
Invoked upon completion of bean property configuration for this object.int
Return the action constant to use during relationship checking.boolean
Return whether to manage LRS fields.protected void
removeFromCollection
(OpenJPAStateManager sm, FieldMetaData fmd, Object val) Remove the given instance from the collection.void
setAction
(int action) Set the action constant to use during relationship checking.void
Set the action string to use during relationship checking.void
Invoked prior to setting bean properties.void
setManageLRS
(boolean manage) Set whether to false LRS relations.void
Invoked before bean property configuration is begun on this object.protected void
storeField
(OpenJPAStateManager sm, FieldMetaData fmd, Object compare, Object val) Store a given value at the given field.protected void
storeNull
(OpenJPAStateManager sm, FieldMetaData fmd, Object compare) Store null value at the given field.protected void
Throw an inconsistency exceptionprotected void
Log an inconsistency warning
-
Field Details
-
NONE
-
_mgr
-
ACTION_MANAGE
public static final int ACTION_MANAGEConstant representing theACTION_MANAGE
action- See Also:
-
ACTION_WARN
public static final int ACTION_WARNConstant representing theACTION_WARN
action- See Also:
-
ACTION_EXCEPTION
public static final int ACTION_EXCEPTIONConstant representing theACTION_EXCEPTION
action- See Also:
-
-
Constructor Details
-
InverseManager
public InverseManager()
-
-
Method Details
-
getManageLRS
public boolean getManageLRS()Return whether to manage LRS fields. -
setManageLRS
public void setManageLRS(boolean manage) Set whether to false LRS relations. Defaults to false. -
getAction
public int getAction()Return the action constant to use during relationship checking. Defaults toACTION_MANAGE
. -
setAction
public void setAction(int action) Set the action constant to use during relationship checking. Defaults toACTION_MANAGE
. -
setAction
Set the action string to use during relationship checking. Options includemanage, exception, warn
. This method is primarily for string-based automated configuration. -
startConfiguration
public void startConfiguration()Description copied from interface:Configurable
Invoked before bean property configuration is begun on this object.- Specified by:
startConfiguration
in interfaceConfigurable
-
endConfiguration
public void endConfiguration()Description copied from interface:Configurable
Invoked upon completion of bean property configuration for this object.- Specified by:
endConfiguration
in interfaceConfigurable
-
setConfiguration
Description copied from interface:Configurable
Invoked prior to setting bean properties.- Specified by:
setConfiguration
in interfaceConfigurable
-
correctRelations
Correct relations from the given dirty field to inverse instances. Fieldfmd
of the instance managed bysm
has valuevalue
. Ensure that all inverses relations fromvalue
are consistent with this. -
createInverseRelations
protected void createInverseRelations(StoreContext ctx, Object fromRef, Object toRef, FieldMetaData fmd, FieldMetaData[] inverses) Create the inverse relations for all the given inverse fields. A relation exists fromfromRef
totoRef
; this method creates the inverses. -
clearInverseRelations
protected void clearInverseRelations(OpenJPAStateManager sm, FieldMetaData fmd, FieldMetaData[] inverses, Object newValue) Remove all relations between the initial value offmd
for the instance managed bysm
and its inverses. Relations shared withnewValue
can be left intact. -
clearInverseRelations
protected void clearInverseRelations(OpenJPAStateManager sm, Object val, FieldMetaData fmd, FieldMetaData[] inverses) Clear all inverse the relations fromval
to the instance managed bysm
. -
storeNull
Store null value at the given field. Verify that the given compare value is the value being nulled. Pass NONE for no comparison. -
storeField
Store a given value at the given field. Compare the given argument if not NONE. -
removeFromCollection
Remove the given instance from the collection. -
addToCollection
Add the given value to the collection at the selected field. -
warnConsistency
Log an inconsistency warning -
throwException
Throw an inconsistency exception
-