EOEntity
Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: EOAccess/EOEntity.h
Class Description
An EOEntity describes a table in a database and associates a name internal to the Framework with an external name by which the table is known to the database. An EOEntity maintains a group of attributes and relationships, which are collectively called properties. These are represented by the EOAttribute and EORelationship classes, respectively; see their specifications for more information.
You usually define entities in a model with the EOModeler application, which is documented in Enterprise Objects Tools and Techniques. EOEntity objects are primarily used by the Enterprise Objects Framework for mapping tables in the database to enterprise objects; your code will probably make limited use of them unless you're specifically working with models.
An EOEntity is associated with a specific class whose instances are used to represent records (rows) from the database in applications using layers at or above the database layer of the Enterprise Objects Framework. If an EOEntity doesn't have a specific class associated with it, instances of EOGenericRecord (defined in EOControl) are created.
An EOEntity may be marked as read-only, in which case any changes to rows or objects for that entity made by the database level objects are denied.
You can define an external query for an EOEntity to be used when a selection is attempted with an unrestricted qualifier (one that would select all rows in the entity's table). An external query is sent unaltered to the database server and so can use database-specific features such as stored procedures; external queries are thus useful for hiding records or invoking database-specific features. You can also assign stored procedures to be invoked upon particular database operations through the use of EOEntity's setStoredProcedure:forOperation: method.
Like the other major modeling classes, EOEntity provides a user dictionary for your application to store any application-specific information related to the entity.
For more information on programmatically creating EOEntity objects, see "Creating an Entity" .
Constants
EOEntityEOAccess defines the following NSString constants in EOEntity.h:
Constant | Description |
EOFetchAllProcedureOperation | A stored procedure to fetch all records |
EOFetchWithPrimaryKeyProcedureOperation | A stored procedure to fetch by primary key |
EOInsertProcedureOperation | A stored procedure to insert a row |
EODeleteProcedureOperation | A stored procedure to delete a row |
EONextPrimaryKeyProcedureOperation | A stored procedure to generate a new primary key |
Adopted Protocols
EOPropertyListEncoding- initWithPropertyList:owner: - awakeWithPropertyList - encodeIntoPropertyList:
Method Types
- Accessing the name
- - setName:
- - name
- - validateName:
- - beautifyName
- Accessing the model
- - model
- Specifying fetching behavior for the entity
- - setExternalQuery:
- - externalQuery
- - setRestrictingQualifier:
- - restrictingQualifier
- Accessing primary key qualifiers
- - qualifierForPrimaryKey:
- - isQualifierForPrimaryKey:
- Accessing attributes
- - addAttribute:
- - anyAttributeNamed:
- - attributeNamed:
- - attributes
- - removeAttribute:
- - attributesToFetch
- Accessing relationships
- - addRelationship:
- - anyRelationshipNamed:
- - relationships
- - relationshipNamed:
- - removeRelationship:
- Checking referential integrity
- - externalModelsReferenced
- - referencesProperty:
- Accessing primary keys
- - globalIDForRow:
- - isPrimaryKeyValidInObject:
- - primaryKeyForGlobalID:
- - primaryKeyForRow:
- Accessing primary key attributes
- - setPrimaryKeyAttributes:
- - primaryKeyAttributes
- - primaryKeyAttributeNames
- - primaryKeyRootName:
- - isValidPrimaryKeyAttribute:
- Accessing class properties
- - setClassProperties:
- - classProperties
- - classPropertyNames
- - isValidClassProperty:
- Accessing the enterprise object class
- - classDescriptionForInstances
- - setClassName:
- - className
- Accessing locking attributes
- - setAttributesUsedForLocking:
- - attributesUsedForLocking
- - isValidAttributeUsedForLocking:
- Accessing external name
- - setExternalName:
- - externalName
- Accessing whether an entity is read only
- - setReadOnly:
- - isReadOnly
- Accessing the user dictionary
- - setUserInfo:
- - userInfo
- Working with stored procedures
- - setStoredProcedure:forOperation:
- - storedProcedureForOperation:
- Working with fetch specifications
- - addFetchSpecification:withName:
- - fetchSpecificationNamed:
- - fetchSpecificationNames
- - removeFetchSpecificationNamed:
- - addSharedObjectFetchSpecificationByName:
- - sharedObjectFetchSpecificationNames
- - setSharedObjectFetchSpecificationsByName:
- - removeSharedObjectFetchSpecificationByName:
- Working with entity inheritance hierarchies
- - parentEntity
- - subEntities
- - addSubEntity:
- - removeSubEntity:
- - setIsAbstractEntity:
- - isAbstractEntity
- Specifying fault behavior
- - setMaxNumberOfInstancesToBatchFetch:
- - maxNumberOfInstancesToBatchFetch
- Caching objects
- - setCachesObjects:
- - cachesObjects
Instance Methods
addAttribute:
- (void)addAttribute:(EOAttribute
*)anAttribute
NSInvalidArgumentException
if anAttribute's
name is already in use by another attribute or relationship. Sets anAttribute's
entity to self.See Also: - removeAttribute:, - attributes, - attributeNamed:
addFetchSpecification:withName:
- (void)addFetchSpecification:(EOFetchSpecification
*)fetchSpec
withName:(NSString *)fetchSpecName
See Also: - fetchSpecificationNamed:, - fetchSpecificationNames, - removeFetchSpecificationNamed:
addRelationship:
- (void)addRelationship:(EORelationship
*)aRelationship
NSInvalidArgumentException
if aRelationship's
name is already in use by another attribute or relationship. Sets aRelationship's
entity to self.See Also: - removeRelationship:, - relationships, - relationshipNamed:
addSharedObjectFetchSpecificationByName:
- (void)addSharedObjectFetchSpecificationByName:(NSString
*)name
addSubEntity:
- (void)addSubEntity:(EOEntity
*)child
See Also: - subEntities, - removeSubEntity:
anyAttributeNamed:
- (EOAttribute *)anyAttributeNamed:(NSString
*)attributeName
See Also: - attributeNamed:, - attributes
anyRelationshipNamed:
- (EORelationship *)anyRelationshipNamed:(NSString
*)relationshipName
See Also: - relationshipNamed:, - relationships
attributeNamed:
- (EOAttribute *)attributeNamed:(NSString
*)attributeName
See Also: - anyAttributeNamed:, - attributes, - relationshipNamed:
attributes
- (NSArray *)attributes
See Also: - anyAttributeNamed:, - attributeNamed:
attributesToFetch
- (NSArray *)attributesToFetch
- Attributes that are class properties, "used for locking," or primary keys.
- Source attributes of any to-many relationship (flattened or non-flattened) that is a class property.
- Source attributes of any non-flattened, to-one relationship that is a class property or that is used by a flattened attribute that is a class property.
- The foreign key attributes of any flattened, to-one relationship that is a class property or that is used by a class property.
attributesUsedForLocking
- (NSArray *)attributesUsedForLocking
Attributes used for locking are those whose values are compared when a database-level object performs an update. When the database-level classes fetch an enterprise object, they cache these attributes' values in a snapshot. Later, when the enterprise object is updated, the values of these attributes in the object are checked with those in the snapshot-if they differ, the update fails. See the EODatabaseContext class specification for more information.
beautifyName
- (void)beautifyName
See Also: - setName:, - validateName:, - beautifyNames (EOModel)
cachesObjects
- (BOOL)cachesObjects
See Also: - setCachesObjects:
classDescriptionForInstances
- (EOClassDescription *)classDescriptionForInstances
className
- (NSString *)className
An enterprise object class other than EOGenericRecord can be mapped to only one entity.
classProperties
- (NSArray *)classProperties
See Also: - classPropertyNames
classPropertyNames
- (NSArray *)classPropertyNames
See Also: - classProperties
externalModelsReferenced
- (NSArray *)externalModelsReferenced
See Also: - referencesProperty:
externalName
- (NSString *)externalName
externalQuery
- (NSString *)externalQuery
External queries are useful for hiding records or invoking database-specific features such as stored procedures when an application attempts to select all records for an entity. You can also use the EOStoredProcedure class to work with stored procedures; for more information see the EOStoredProcedure class specification.
See Also: - setExternalQuery:
fetchSpecificationNamed:
- (EOFetchSpecification *)fetchSpecificationNamed:(NSString
*)fetchSpecName
See Also: - addFetchSpecification:withName:, - fetchSpecificationNames, - removeFetchSpecificationNamed:
fetchSpecificationNames
- (NSArray *)fetchSpecificationNames
See Also: - addFetchSpecification:withName:, - fetchSpecificationNamed:, - removeFetchSpecificationNamed:
globalIDForRow:
- (EOGlobalID *)globalIDForRow:(NSDictionary
*)row
See Also: - primaryKeyForGlobalID:
isAbstractEntity
- (BOOL)isAbstractEntity
See Also: - setIsAbstractEntity:
isPrimaryKeyValidInObject:
- (BOOL)isPrimaryKeyValidInObject:(id)anObject
See Also: - primaryKeyForRow:
isQualifierForPrimaryKey:
- (BOOL)isQualifierForPrimaryKey:(EOQualifier
*)aQualifier
isReadOnly
- (BOOL)isReadOnly
isValidAttributeUsedForLocking:
- (BOOL)isValidAttributeUsedForLocking:(EOAttribute
*)anAttribute
See Also: - attributesUsedForLocking
isValidClassProperty:
- (BOOL)isValidClassProperty:(id)aProperty
isValidPrimaryKeyAttribute:
- (BOOL)isValidPrimaryKeyAttribute:(EOAttribute
*)anAttribute
See Also: - setPrimaryKeyAttributes:
maxNumberOfInstancesToBatchFetch
- (unsigned int)maxNumberOfInstancesToBatchFetch
model
- (EOModel *)model
See Also: - addEntity: (EOModel)
name
- (NSString *)name
parentEntity
- (EOEntity *)parentEntity
See Also: - subEntities
primaryKeyAttributeNames
- (NSArray *)primaryKeyAttributeNames
See Also: - primaryKeyAttributes
primaryKeyAttributes
- (NSArray *)primaryKeyAttributes
See Also: - primaryKeyAttributeNames
primaryKeyForGlobalID:
- (NSDictionary *)primaryKeyForGlobalID:(EOKeyGlobalID
*)globalID
See Also: - globalIDForRow:
primaryKeyForRow:
- (NSDictionary *)primaryKeyForRow:(NSDictionary
*)aRow
See Also: - primaryKeyForGlobalID:
primaryKeyRootName:
- (NSString *)primaryKeyRootName
See Also: - externalName, - name, - parentEntity
qualifierForPrimaryKey:
- (EOQualifier *)qualifierForPrimaryKey:(NSDictionary
*)aRow
See Also: - isQualifierForPrimaryKey:, - restrictingQualifier
referencesProperty:
- (BOOL)referencesProperty:(id)aProperty
If an entity has any outstanding references to a property, you shouldn't remove the property.
See Also: - removeAttribute:, - removeRelationship:
relationshipNamed:
- (EORelationship *)relationshipNamed:(NSString
*)name
See Also: - anyRelationshipNamed:, - attributeNamed:, - relationships
relationships
- (NSArray *)relationships
See Also: - attributes
removeAttribute:
- (void)removeAttribute:(EOAttribute
*)name
See Also: - addAttribute:, - attributes
removeFetchSpecificationNamed:
- (void)removeFetchSpecificationNamed:(NSString
*)fetchSpecName
See Also: - addFetchSpecification:withName:, - fetchSpecificationNamed:, - fetchSpecificationNames
removeRelationship:
- (void)removeRelationship:(EORelationship
*)name
See Also: - addRelationship:, - relationships
removeSharedObjectFetchSpecificationByName:
- (void)removeSharedObjectFetchSpecificationByName:(NSString
*)name
removeSubEntity:
- (void)removeSubEntity:(EOEntity
*)child
See Also: - addSubEntity:, - subEntities
restrictingQualifier
- (EOQualifier *)restrictingQualifier
For example, if you're using the "one table" inheritance model in which parent and child data is contained in the same table, you'd use a restricting qualifier to fetch objects of the appropriate type. To give a non-inheritance example, for an Employees table you might create a "Sales" entity that has a restricting qualifier that only fetches employees who are in the Sales department.
See Also: - setRestrictingQualifier:
setAttributesUsedForLocking:
- (BOOL)setAttributesUsedForLocking:(NSArray
*)attributes
setCachesObjects:
- (void)setCachesObjects:(BOOL)flag
See Also: - cachesObjects
setClassName:
- (void)setClassName:(NSString
*)name
An enterprise object class other than EOGenericRecord can be mapped to only one entity.
See Also: - className
setClassProperties:
- (BOOL)setClassProperties:(NSArray
*)properties
setExternalName:
- (void)setExternalName:(NSString
*)name
setExternalQuery:
- (void)setExternalQuery:(NSString
*)aQuery
External queries are useful for hiding records or invoking database-specific features such as stored procedures when an application attempts to select all records for an entity. You can also use the EOStoredProcedure class to work with stored procedures; for more information see the EOStoredProcedure class specification.
An external query is sent unaltered to the database server, and so must contain the external (column) names instead of the names of EOAttributes. However, to work properly with the adaptor the external query must use the columns in alphabetical order by their corresponding EOAttributes' names.
See Also: - columnName (EOAttribute), - externalQuery
setIsAbstractEntity:
- (void)setIsAbstractEntity:(BOOL)flag
setMaxNumberOfInstancesToBatchFetch:
- (void)setMaxNumberOfInstancesToBatchFetch:(unsigned
int)size
See Also: - maxNumberOfInstancesToBatchFetch
setName:
- (void)setName:(NSString
*)name
NSInvalidArgumentException
if name is
already in use by another entity in the same EOModel or if name is
not a valid entity name.See Also: - beautifyName, - validateName:
setPrimaryKeyAttributes:
- (BOOL)setPrimaryKeyAttributes:(NSArray
*)keys
You should exercise care in choosing primary key attributes. Floating-point numbers, for example, can't be reliably compared for equality, and are thus unsuitable for use in primary keys. Integer and string types are the safest choice for primary keys. NSDecimalNumber objects will work, but they'll entail more overhead than integers.
See Also: - isValidPrimaryKeyAttribute:
setReadOnly:
- (void)setReadOnly:(BOOL)flag
See Also: - isReadOnly
setRestrictingQualifier:
- (void)setRestrictingQualifier:(EOQualifier
*)aQualifier
setSharedObjectFetchSpecificationsByName:
- (void)setSharedObjectFetchSpecificationsByName:(NSArray
*)names
setStoredProcedure:forOperation:
- (void)setStoredProcedure:(EOStoredProcedure
*)storedProcedure
forOperation:(NSString *)operation
- EOFetchAllProcedureOperation
- EOFetchWithPrimaryKeyProcedureOperation
- EOInsertProcedureOperation
- EODeleteProcedureOperation
- EONextPrimaryKeyProcedureOperation
This information is used when changes from the object graph have been transformed into EODatabaseOperations that are being used to construct EOAdaptorOperations. At this point, Enterprise Objects Framework checks the entities associated with the changed objects to see if the entities have any stored procedures defined for the operation being performed.
See Also: - storedProcedureForOperation:
setUserInfo:
- (void)setUserInfo:(NSDictionary
*)dictionary
sharedObjectFetchSpecificationNames
- (NSArray *)sharedObjectFetchSpecificationNames
storedProcedureForOperation:
- (EOStoredProcedure *)storedProcedureForOperation:(NSString
*)operation
- EOFetchAllProcedureOperation
- EOFetchWithPrimaryKeyProcedureOperation
- EOInsertProcedureOperation
- EODeleteProcedureOperation
- EONextPrimaryKeyProcedureOperation
See Also: - setStoredProcedure:forOperation:, - parameterDirection (EOAttribute), - storedProcedure (EOAttribute)
subEntities
- (NSArray *)subEntities
See Also: - addSubEntity:, - parentEntity, - removeSubEntity:
userInfo
- (NSDictionary *)userInfo
See Also: - setUserInfo:
validateName:
- (NSException *)validateName:(NSString
*)name
setName: uses this method to validate its argument.