Skip to main content
[ This file is autogenerated from apexdoc ]

AqSObjectUnitOfWork

Group modules/enterprise

Constructors​

public AqSObjectUnitOfWork(List<Schema.SObjectType> givenSObjectTypes)​

Constructs a new UnitOfWork to support work against the given object list

Parameters​

ParamDescription
givenSObjectTypesA list of objects given in dependency order (least dependent first)

Fields​

protected sObjectTypes → List<Schema.SObjectType>​

protected newListByType → Map<String,List<SObject>>​

protected dirtyMapByType → Map<String,Map<Id,SObject>>​

protected deletedMapByType → Map<String,Map<Id,SObject>>​

protected relationships → Map<String,Relationships>​


Methods​

public void registerNew(SObject record)​

Register a newly created SObject instance to be inserted when commitWork is called

Parameters​

ParamDescription
recordA newly created SObject instance to be inserted during commitWork

public void registerNew(List<SObject> records)​

Register a list of newly created SObject instances to be inserted when commitWork is called

Parameters​

ParamDescription
recordsA list of newly created SObject instances to be inserted during commitWork

public void registerNew(SObject record, Schema relatedToParentField, SObject relatedToParentRecord)​

Register a newly created SObject instance to be inserted when commitWork is called, you may also provide a reference to the parent record instance (should also be registered as new separately)

Parameters​

ParamDescription
recordA newly created SObject instance to be inserted during commitWork
relatedToParentFieldA SObjectField reference to the child field that associates the child record with its parent
relatedToParentRecordA SObject instance of the parent record (should also be registered as new separately)

public void registerRelationship(SObject record, Schema relatedToField, SObject relatedTo)​

Register a relationship between two records that have yet to be inserted to the database. This information will be used during the commitWork phase to make the references only when related records have been inserted to the database.

Parameters​

ParamDescription
recordAn existing or newly created record
relatedToFieldA SObjectField reference to the lookup field that relates the two records together
relatedToA SObject instance (yet to be committed to the database)

public void registerDirty(SObject record)​

Register an existing record to be updated during the commitWork method

Parameters​

ParamDescription
recordAn existing record

public void registerDirty(SObject record, List<SObjectField> dirtyFields)​

public void registerDirty(SObject record, Schema relatedToParentField, SObject relatedToParentRecord)​

Register an existing record to be updated when commitWork is called, you may also provide a reference to the parent record instance (should also be registered as new separately)

Parameters​

ParamDescription
recordA newly created SObject instance to be inserted during commitWork
relatedToParentFieldA SObjectField reference to the child field that associates the child record with its parent
relatedToParentRecordA SObject instance of the parent record (should also be registered as new separately)

public void registerDirty(List<SObject> records)​

Register a list of existing records to be updated during the commitWork method

Parameters​

ParamDescription
recordsA list of existing records

public void registerUpsert(SObject record)​

Register a new or existing record to be inserted/updated during the commitWork method

Parameters​

ParamDescription
recordA new or existing record

public void registerUpsert(List<SObject> records)​

Register a list of mix of new and existing records to be inserted updated during the commitWork method

Parameters​

ParamDescription
recordsA list of mix of new and existing records

public void registerDeleted(SObject record)​

Register an existing record to be deleted during the commitWork method

Parameters​

ParamDescription
recordAn existing record

public void registerDeleted(List<SObject> records)​

Register a list of existing records to be deleted during the commitWork method

Parameters​

ParamDescription
recordsA list of existing records

public void commitWork()​

Takes all the work that has been registered with the UnitOfWork and commits it to the database

public static AqSObjectUnitOfWork createInstance()​