Package org.apache.openjpa.kernel
Class InverseManager
- java.lang.Object
-
- org.apache.openjpa.kernel.InverseManager
-
- All Implemented Interfaces:
Configurable
public class InverseManager extends Object implements 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
Fields Modifier and Type Field Description protected DataCacheManager_mgrstatic intACTION_EXCEPTIONConstant representing theACTION_EXCEPTIONactionstatic intACTION_MANAGEConstant representing theACTION_MANAGEactionstatic intACTION_WARNConstant representing theACTION_WARNactionprotected static ObjectNONE
-
Constructor Summary
Constructors Constructor Description InverseManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddToCollection(OpenJPAStateManager sm, FieldMetaData fmd, Object val)Add the given value to the collection at the selected field.protected voidclearInverseRelations(OpenJPAStateManager sm, Object val, FieldMetaData fmd, FieldMetaData[] inverses)Clear all inverse the relations fromvalto the instance managed bysm.protected voidclearInverseRelations(OpenJPAStateManager sm, FieldMetaData fmd, FieldMetaData[] inverses, Object newValue)Remove all relations between the initial value offmdfor the instance managed bysmand its inverses.voidcorrectRelations(OpenJPAStateManager sm, FieldMetaData fmd, Object value)Correct relations from the given dirty field to inverse instances.protected voidcreateInverseRelations(StoreContext ctx, Object fromRef, Object toRef, FieldMetaData fmd, FieldMetaData[] inverses)Create the inverse relations for all the given inverse fields.voidendConfiguration()Invoked upon completion of bean property configuration for this object.intgetAction()Return the action constant to use during relationship checking.booleangetManageLRS()Return whether to manage LRS fields.protected voidremoveFromCollection(OpenJPAStateManager sm, FieldMetaData fmd, Object val)Remove the given instance from the collection.voidsetAction(int action)Set the action constant to use during relationship checking.voidsetAction(String action)Set the action string to use during relationship checking.voidsetConfiguration(Configuration conf)Invoked prior to setting bean properties.voidsetManageLRS(boolean manage)Set whether to false LRS relations.voidstartConfiguration()Invoked before bean property configuration is begun on this object.protected voidstoreField(OpenJPAStateManager sm, FieldMetaData fmd, Object compare, Object val)Store a given value at the given field.protected voidstoreNull(OpenJPAStateManager sm, FieldMetaData fmd, Object compare)Store null value at the given field.protected voidthrowException(OpenJPAStateManager sm, FieldMetaData fmd)Throw an inconsistency exceptionprotected voidwarnConsistency(OpenJPAStateManager sm, FieldMetaData fmd)Log an inconsistency warning
-
-
-
Field Detail
-
NONE
protected static final Object NONE
-
_mgr
protected DataCacheManager _mgr
-
ACTION_MANAGE
public static final int ACTION_MANAGE
Constant representing theACTION_MANAGEaction- See Also:
- Constant Field Values
-
ACTION_WARN
public static final int ACTION_WARN
Constant representing theACTION_WARNaction- See Also:
- Constant Field Values
-
ACTION_EXCEPTION
public static final int ACTION_EXCEPTION
Constant representing theACTION_EXCEPTIONaction- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public void setAction(String action)
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:ConfigurableInvoked before bean property configuration is begun on this object.- Specified by:
startConfigurationin interfaceConfigurable
-
endConfiguration
public void endConfiguration()
Description copied from interface:ConfigurableInvoked upon completion of bean property configuration for this object.- Specified by:
endConfigurationin interfaceConfigurable
-
setConfiguration
public void setConfiguration(Configuration conf)
Description copied from interface:ConfigurableInvoked prior to setting bean properties.- Specified by:
setConfigurationin interfaceConfigurable
-
correctRelations
public void correctRelations(OpenJPAStateManager sm, FieldMetaData fmd, Object value)
Correct relations from the given dirty field to inverse instances. Fieldfmdof the instance managed bysmhas valuevalue. Ensure that all inverses relations fromvalueare 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 fromfromReftotoRef; this method creates the inverses.
-
clearInverseRelations
protected void clearInverseRelations(OpenJPAStateManager sm, FieldMetaData fmd, FieldMetaData[] inverses, Object newValue)
Remove all relations between the initial value offmdfor the instance managed bysmand its inverses. Relations shared withnewValuecan be left intact.
-
clearInverseRelations
protected void clearInverseRelations(OpenJPAStateManager sm, Object val, FieldMetaData fmd, FieldMetaData[] inverses)
Clear all inverse the relations fromvalto the instance managed bysm.
-
storeNull
protected void storeNull(OpenJPAStateManager sm, FieldMetaData fmd, Object compare)
Store null value at the given field. Verify that the given compare value is the value being nulled. Pass NONE for no comparison.
-
storeField
protected void storeField(OpenJPAStateManager sm, FieldMetaData fmd, Object compare, Object val)
Store a given value at the given field. Compare the given argument if not NONE.
-
removeFromCollection
protected void removeFromCollection(OpenJPAStateManager sm, FieldMetaData fmd, Object val)
Remove the given instance from the collection.
-
addToCollection
protected void addToCollection(OpenJPAStateManager sm, FieldMetaData fmd, Object val)
Add the given value to the collection at the selected field.
-
warnConsistency
protected void warnConsistency(OpenJPAStateManager sm, FieldMetaData fmd)
Log an inconsistency warning
-
throwException
protected void throwException(OpenJPAStateManager sm, FieldMetaData fmd)
Throw an inconsistency exception
-
-