Package org.castor.persist.resolver
Class ManyToManyRelationResolver
java.lang.Object
org.castor.persist.resolver.BaseRelationResolver
org.castor.persist.resolver.ManyRelationResolver
org.castor.persist.resolver.ManyToManyRelationResolver
- All Implemented Interfaces:
ResolverStrategy
Implementation of
ResolverStrategy for M:N relations.- Since:
- 0.9.9
- Author:
- Werner Guttmann
-
Field Summary
Fields inherited from class org.castor.persist.resolver.BaseRelationResolver
_classMolder, _fieldMolder -
Constructor Summary
ConstructorsConstructorDescriptionManyToManyRelationResolver(ClassMolder classMolder, FieldMolder fieldMolder, int fieldIndex) Creates an instance of ManyToManyRelationResolver. -
Method Summary
Modifier and TypeMethodDescriptionbooleanmarkCreate(TransactionContext tx, OID oid, Object object) Walk the object model and mark object that should be created.voidmarkDelete(TransactionContext tx, Object object, Object field) Prepare to delete an object with the specified identity.postCreate(TransactionContext tx, OID oid, Object object, Object field, Identity createdId) Called after successful creation of an object of the base class.preStore(TransactionContext tx, OID oid, Object object, int timeout, Object field) Check the object for modification.voidupdate(TransactionContext tx, OID oid, Object object, AccessMode suggestedAccessMode, Object field) Update the object which loaded or created in the other transaction to the persistent storage.booleanupdateWhenNoTimestampSet(TransactionContext tx, OID oid, Object object, AccessMode suggestedAccessMode) Update the object which loaded or created in the other transaction to the persistent storage.Methods inherited from class org.castor.persist.resolver.ManyRelationResolver
create, expireCache, load, removeRelation, revertObject, store, updateCacheMethods inherited from class org.castor.persist.resolver.BaseRelationResolver
isCascadingCreate, isCascadingDelete, isCascadingUpdate
-
Constructor Details
-
ManyToManyRelationResolver
Creates an instance of ManyToManyRelationResolver.- Parameters:
classMolder- Associated ClassMolder.fieldMolder- Associated FieldMolder.fieldIndex- Field index within all fields of parent class molder.
-
-
Method Details
-
markCreate
public boolean markCreate(TransactionContext tx, OID oid, Object object) throws PersistenceException Description copied from interface:ResolverStrategyWalk the object model and mark object that should be created.- Specified by:
markCreatein interfaceResolverStrategy- Specified by:
markCreatein classManyRelationResolver- Parameters:
tx- transaction in actionoid- the object identity of the object to be created.object- the object to be created- Returns:
- true if there's objects that should be created
- Throws:
PersistenceException- See Also:
-
markDelete
public void markDelete(TransactionContext tx, Object object, Object field) throws PersistenceException Description copied from interface:ResolverStrategyPrepare to delete an object with the specified identity. If any sub-object should be deleted along with the target object, it should be deleted by this method.- Specified by:
markDeletein interfaceResolverStrategy- Specified by:
markDeletein classManyRelationResolver- Parameters:
tx- - transaction in actionobject- - the target objectfield- The field value as returned by the SQLEngine- Throws:
PersistenceException- If it is not possible to successfully complete this method.- See Also:
-
preStore
public UpdateFlags preStore(TransactionContext tx, OID oid, Object object, int timeout, Object field) throws PersistenceException Description copied from interface:ResolverStrategyCheck the object for modification. If dpendent object is dereferenced, it method will remove the object thru the transaction. If an related object is dereferenced, it method will make sure the formally object will be dereferenced from the other side as well. This method is called in prepare (for commit) state of the transaction. This method indicates if the object needed to be persist or cache should be update using TransactionContext.markDelete.- Specified by:
preStorein interfaceResolverStrategy- Specified by:
preStorein classManyRelationResolver- Parameters:
tx- transaction in actionoid- the object identity of the objectobject- the data object to be checkedtimeout- timeout of updating the lock if neededfield- The field value as returned by the SQLEngine- Returns:
- true if the object is modified
- Throws:
PersistenceException- If it is not possible to successfully complete this method.- See Also:
-
update
public void update(TransactionContext tx, OID oid, Object object, AccessMode suggestedAccessMode, Object field) throws PersistenceException Description copied from interface:ResolverStrategyUpdate the object which loaded or created in the other transaction to the persistent storage.- Specified by:
updatein interfaceResolverStrategy- Specified by:
updatein classManyRelationResolver- Parameters:
tx- Transaction in actionoid- the object identity of the stored objectobject- the object to be storedsuggestedAccessMode- Suggested access modefield- The field value as returned by the SQLEngine- Throws:
PersistenceException- If it is not possible to successfully complete this method.- See Also:
-
postCreate
public Object postCreate(TransactionContext tx, OID oid, Object object, Object field, Identity createdId) throws PersistenceException Description copied from interface:ResolverStrategyCalled after successful creation of an object of the base class.- Specified by:
postCreatein interfaceResolverStrategy- Specified by:
postCreatein classManyRelationResolver- Parameters:
tx- transaction in actionoid- the object identity of the object to be created.object- the object to be createdfield- The field value as returned by the SQLEnginecreatedId- ???- Returns:
- the identity of the object
- Throws:
PersistenceException- See Also:
-
updateWhenNoTimestampSet
public boolean updateWhenNoTimestampSet(TransactionContext tx, OID oid, Object object, AccessMode suggestedAccessMode) throws PersistenceException Description copied from interface:ResolverStrategyUpdate the object which loaded or created in the other transaction to the persistent storage.- Parameters:
tx- Transaction in actionoid- the object identity of the stored objectobject- the object to be storedsuggestedAccessMode- Suggested access mode- Returns:
- TODO
- Throws:
PersistenceException- If it is not possible to successfully complete this method.
-