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
public final class ManyToManyRelationResolver extends ManyRelationResolver
Implementation ofResolverStrategy
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
Constructors Constructor Description ManyToManyRelationResolver(ClassMolder classMolder, FieldMolder fieldMolder, int fieldIndex)
Creates an instance of ManyToManyRelationResolver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
markCreate(TransactionContext tx, OID oid, java.lang.Object object)
Walk the object model and mark object that should be created.void
markDelete(TransactionContext tx, java.lang.Object object, java.lang.Object field)
Prepare to delete an object with the specified identity.java.lang.Object
postCreate(TransactionContext tx, OID oid, java.lang.Object object, java.lang.Object field, Identity createdId)
Called after successful creation of an object of the base class.UpdateFlags
preStore(TransactionContext tx, OID oid, java.lang.Object object, int timeout, java.lang.Object field)
Check the object for modification.void
update(TransactionContext tx, OID oid, java.lang.Object object, AccessMode suggestedAccessMode, java.lang.Object field)
Update the object which loaded or created in the other transaction to the persistent storage.boolean
updateWhenNoTimestampSet(TransactionContext tx, OID oid, java.lang.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, updateCache
-
Methods inherited from class org.castor.persist.resolver.BaseRelationResolver
isCascadingCreate, isCascadingDelete, isCascadingUpdate
-
-
-
-
Constructor Detail
-
ManyToManyRelationResolver
public ManyToManyRelationResolver(ClassMolder classMolder, FieldMolder fieldMolder, int fieldIndex)
Creates an instance of ManyToManyRelationResolver.- Parameters:
classMolder
- Associated ClassMolder.fieldMolder
- Associated FieldMolder.fieldIndex
- Field index within all fields of parent class molder.
-
-
Method Detail
-
markCreate
public boolean markCreate(TransactionContext tx, OID oid, java.lang.Object object) throws PersistenceException
Description copied from interface:ResolverStrategy
Walk the object model and mark object that should be created.- Specified by:
markCreate
in interfaceResolverStrategy
- Specified by:
markCreate
in 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:
#markCreate(org.castor.persist.TransactionContext, org.exolab.castor.persist.OID, java.lang.Object)
-
markDelete
public void markDelete(TransactionContext tx, java.lang.Object object, java.lang.Object field) throws PersistenceException
Description copied from interface:ResolverStrategy
Prepare 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:
markDelete
in interfaceResolverStrategy
- Specified by:
markDelete
in 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:
#markDelete(org.castor.persist.TransactionContext, java.lang.Object, java.lang.Object)
-
preStore
public UpdateFlags preStore(TransactionContext tx, OID oid, java.lang.Object object, int timeout, java.lang.Object field) throws PersistenceException
Description copied from interface:ResolverStrategy
Check 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:
preStore
in interfaceResolverStrategy
- Specified by:
preStore
in 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:
#preStore(org.castor.persist.TransactionContext, org.exolab.castor.persist.OID, java.lang.Object, int, java.lang.Object)
-
update
public void update(TransactionContext tx, OID oid, java.lang.Object object, AccessMode suggestedAccessMode, java.lang.Object field) throws PersistenceException
Description copied from interface:ResolverStrategy
Update the object which loaded or created in the other transaction to the persistent storage.- Specified by:
update
in interfaceResolverStrategy
- Specified by:
update
in 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:
#update(org.castor.persist.TransactionContext, org.exolab.castor.persist.OID, java.lang.Object, org.exolab.castor.mapping.AccessMode, java.lang.Object)
-
postCreate
public java.lang.Object postCreate(TransactionContext tx, OID oid, java.lang.Object object, java.lang.Object field, Identity createdId) throws PersistenceException
Description copied from interface:ResolverStrategy
Called after successful creation of an object of the base class.- Specified by:
postCreate
in interfaceResolverStrategy
- Specified by:
postCreate
in 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:
ManyRelationResolver.postCreate( org.castor.persist.TransactionContext, org.exolab.castor.persist.OID, java.lang.Object, java.lang.Object, org.exolab.castor.persist.spi.Identity)
-
updateWhenNoTimestampSet
public boolean updateWhenNoTimestampSet(TransactionContext tx, OID oid, java.lang.Object object, AccessMode suggestedAccessMode) throws PersistenceException
Description copied from interface:ResolverStrategy
Update 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.
-
-