Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > EOAdaptor Reference

Table of Contents

EODatabaseOperation


Inherits from: NSObject
Package: com.apple.yellow.eoaccess


Class Description


An EODatabaseOperation object represents an operation-insert, update, or delete-to perform on an enterprise object and all the necessary information required to perform the operation. You don't ordinarily create instances of EODatabaseOperation; rather, the Framework automatically creates an EODatabaseOperation object for each new, updated, or deleted object in an EOEditingContext. An EODatabaseContext object analyzes a set of database operations and maps each operation to one or more adaptor operations. The adaptor operations are then performed by an EOAdaptorChannel object. You generally interact with EODatabaseOperation objects only if you need to specify the order in which a set of operations are carried out (see the description for the EODatabaseContext delegate method databaseContextWillOrderAdaptorOperations).

An EODatabaseOperation specifies an enterprise object (called "object") on which the operation is performed, the EOGlobalID for the object, and the object's entity. In addition, the database operation has a snapshot containing the last known database values for the object and a newRow dictionary of new or updated values to save in the database.




Constants


EODatabaseOperation defines the following int constants to identify the primitive database operation represented by an EOAdaptorOperation object or an EODatabaseOperation object:


EOAdaptorOperation Operators EODatabaseOperation Operators
AdaptorLockOperator DatabaseNothingOperator
AdaptorInsertOperator DatabaseInsertOperator
AdaptorUpdateOperator DatabaseUpdateOperator
AdaptorDeleteOperator DatabaseDeleteOperator
AdaptorStoredProcedureOperator  



Method Types


Constructors
EODatabaseOperation
Accessing the global ID object
globalID
Accessing the object
object
Accessing the entity
entity
Accessing the operator
setDatabaseOperator
databaseOperator
Accessing the database snapshot
setDBSnapshot
dbSnapshot
Accessing the row
setNewRow
newRow
Accessing the adaptor operations
addAdaptorOperation
removeAdaptorOperation
adaptorOperations
Comparing new row and snapshot values
rowDiffs
rowDiffsForAttributes
Working with to-many snapshots
recordToManySnapshot
toManySnapshots


Constructors



EODatabaseOperation

public EODatabaseOperation( com.apple.yellow.eocontrol.EOGlobalID aGlobalID, Object anObject, EOEntity anEntity)

Creates and returns a new EODatabaseOperation object, setting the object to which the operation will be applied to anObject, globalID to aGlobalID, and entity to anEntity.


Instance Methods



adaptorOperations

public NSArray adaptorOperations()

Returns the EOAdaptorOperation objects that need to be performed to carry out the operation represented by the receiver.

See Also: addAdaptorOperation, removeAdaptorOperation



addAdaptorOperation

public void addAdaptorOperation(EOAdaptorOperation adaptorOperation)

Adds adaptorOperation to the receiver's list of adaptor operations. Throws an exception if adaptorOperation is null.

See Also: adaptorOperations, removeAdaptorOperation



databaseOperator

public int databaseOperator()

Returns the receiver's database operator.

dbSnapshot

public NSDictionary dbSnapshot()

Returns the database snapshot for the receiver's enterprise object. The snapshot contains the last known database values for the enterprise object. The dictionary returned from this method will be empty if the receiver's object has just been inserted into an EOEditingContext and has not yet been saved in persistent storage. For more information on EOEditingContexts, see the EOEditingContext class specification in the EOControl framework.

See Also: setDatabaseOperator



entity

public EOEntity entity()

Returns the entity that corresponds to the receiver's enterprise object.

See Also: EODatabaseOperation



globalID

public com.apple.yellow.eocontrol.EOGlobalID globalID()

Returns the EOGlobalID object that corresponds to the receiver's enterprise object.

See Also: EODatabaseOperation



newRow

public NSMutableDictionary newRow()

Returns a dictionary representation of the receiver's enterprise object. In addition to all the properties of the enterprise object that are stored in the database, the dictionary contains values for the non-derived attribute's of the enterprise object's entity that aren't visible in the enterprise object. For example, primary and foreign keys aren't ordinarily properties of an enterprise object but are attributes of the object's entity.

The newRow dictionary is initialized with the values in the receiver's snapshot. New or updated values are added to the newRow dictionary (replacing out-of-date values) as the Framework maps changes in the object to an operation.



object

public Object object()

Returns the receiver's enterprise object.

See Also: EODatabaseOperation



primaryKeyDiffs

public NSDictionary primaryKeyDiffs()

Returns a dictionary that contains any primary key values in newRow that are different from those in the dbSnapshot. Returns null if the receiver doesn't have EODatabaseUpdateOperator set as its database operator.

See Also: setDatabaseOperator, newRow



recordToManySnapshot

public void recordToManySnapshot( NSArray globalIDs, String name)

Records the objects in globalIDs. globalIDs is an array of the globalIDs that identify the objects at the destination of the to-many relationship named name; name is a property of the receiver's enterprise object.

See Also: toManySnapshots



removeAdaptorOperation

public void removeAdaptorOperation(EOAdaptorOperation adaptorOperation)

Removes adaptorOperation from the receiver's list of adaptor operations.

See Also: adaptorOperations, addAdaptorOperation



rowDiffs

public NSDictionary rowDiffs()

Returns values in the receiver's newRow dictionary that are different than the corresponding values in its dbSnapshot. The dictionary returned from this method contains the new values from the enterprise object.

See Also: primaryKeyDiffs



rowDiffsForAttributes

public NSDictionary rowDiffsForAttributes(NSArray attributes)

For the EOAttribute objects in attributes, this method returns values in the receiver's newRow dictionary that are different than the corresponding values in its dbSnapshot. The dictionary returned contains the new values from the enterprise object.

setDatabaseOperator

public void setDatabaseOperator(int databaseOperator)

Sets the receiver's database operator. databaseOperator can be one of the following:

setDBSnapshot

public void setDBSnapshot(NSDictionary dbSnapshot)

Sets the snapshot for the receiver's enterprise object. If the object has just been inserted into an an EOEditingContext (EOControl), it won't have a snapshot. In this case, dbSnapshot should be an empty dictionary.

setNewRow

public void setNewRow(NSMutableDictionary newRow)

Sets the dictionary representation of the receiver's enterprise object. newRow should contain values for all the properties of the enterprise object that are stored in the database and for the non-derived attribute's of the enterprise object's entity that aren't visible in the enterprise object.

See Also: databaseOperator



toManySnapshots

public NSDictionary toManySnapshots()

Returns the NSDictionary containing the snapshots for the to-many relationships of the receiver's enterprise object.

See Also: recordToManySnapshot




Table of Contents