Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: EOAccess/EOEntity.h
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" .
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 |
EOPropertyListEncoding- initWithPropertyList:owner: - awakeWithPropertyList - encodeIntoPropertyList:
- 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
- (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:
- (void)addFetchSpecification:(EOFetchSpecification
*)fetchSpec
withName:(NSString *)fetchSpecName
See Also: - fetchSpecificationNamed:, - fetchSpecificationNames, - removeFetchSpecificationNamed:
- (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:
- (void)addSharedObjectFetchSpecificationByName:(NSString
*)name
- (void)addSubEntity:(EOEntity
*)child
See Also: - subEntities, - removeSubEntity:
- (EOAttribute *)anyAttributeNamed:(NSString
*)attributeName
See Also: - attributeNamed:, - attributes
- (EORelationship *)anyRelationshipNamed:(NSString
*)relationshipName
See Also: - relationshipNamed:, - relationships
- (EOAttribute *)attributeNamed:(NSString
*)attributeName
See Also: - anyAttributeNamed:, - attributes, - relationshipNamed:
- (NSArray *)attributes
See Also: - anyAttributeNamed:, - attributeNamed:
- (NSArray *)attributesToFetch
- (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.
- (void)beautifyName
See Also: - setName:, - validateName:, - beautifyNames (EOModel)
- (BOOL)cachesObjects
See Also: - setCachesObjects:
- (EOClassDescription *)classDescriptionForInstances
- (NSString *)className
An enterprise object class other than EOGenericRecord can be mapped to only one entity.
- (NSArray *)classProperties
See Also: - classPropertyNames
- (NSArray *)classPropertyNames
See Also: - classProperties
- (NSArray *)externalModelsReferenced
See Also: - referencesProperty:
- (NSString *)externalName
- (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:
- (EOFetchSpecification *)fetchSpecificationNamed:(NSString
*)fetchSpecName
See Also: - addFetchSpecification:withName:, - fetchSpecificationNames, - removeFetchSpecificationNamed:
- (NSArray *)fetchSpecificationNames
See Also: - addFetchSpecification:withName:, - fetchSpecificationNamed:, - removeFetchSpecificationNamed:
- (EOGlobalID *)globalIDForRow:(NSDictionary
*)row
See Also: - primaryKeyForGlobalID:
- (BOOL)isAbstractEntity
See Also: - setIsAbstractEntity:
- (BOOL)isPrimaryKeyValidInObject:(id)anObject
See Also: - primaryKeyForRow:
- (BOOL)isQualifierForPrimaryKey:(EOQualifier
*)aQualifier
- (BOOL)isReadOnly
- (BOOL)isValidAttributeUsedForLocking:(EOAttribute
*)anAttribute
See Also: - attributesUsedForLocking
- (BOOL)isValidClassProperty:(id)aProperty
- (BOOL)isValidPrimaryKeyAttribute:(EOAttribute
*)anAttribute
See Also: - setPrimaryKeyAttributes:
- (unsigned int)maxNumberOfInstancesToBatchFetch
- (EOModel *)model
See Also: - addEntity: (EOModel)
- (NSString *)name
- (EOEntity *)parentEntity
See Also: - subEntities
- (NSArray *)primaryKeyAttributeNames
See Also: - primaryKeyAttributes
- (NSArray *)primaryKeyAttributes
See Also: - primaryKeyAttributeNames
- (NSDictionary *)primaryKeyForGlobalID:(EOKeyGlobalID
*)globalID
See Also: - globalIDForRow:
- (NSDictionary *)primaryKeyForRow:(NSDictionary
*)aRow
See Also: - primaryKeyForGlobalID:
- (NSString *)primaryKeyRootName
See Also: - externalName, - name, - parentEntity
- (EOQualifier *)qualifierForPrimaryKey:(NSDictionary
*)aRow
See Also: - isQualifierForPrimaryKey:, - restrictingQualifier
- (BOOL)referencesProperty:(id)aProperty
If an entity has any outstanding references to a property, you shouldn't remove the property.
See Also: - removeAttribute:, - removeRelationship:
- (EORelationship *)relationshipNamed:(NSString
*)name
See Also: - anyRelationshipNamed:, - attributeNamed:, - relationships
- (NSArray *)relationships
See Also: - attributes
- (void)removeAttribute:(EOAttribute
*)name
See Also: - addAttribute:, - attributes
- (void)removeFetchSpecificationNamed:(NSString
*)fetchSpecName
See Also: - addFetchSpecification:withName:, - fetchSpecificationNamed:, - fetchSpecificationNames
- (void)removeRelationship:(EORelationship
*)name
See Also: - addRelationship:, - relationships
- (void)removeSharedObjectFetchSpecificationByName:(NSString
*)name
- (void)removeSubEntity:(EOEntity
*)child
See Also: - addSubEntity:, - subEntities
- (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:
- (BOOL)setAttributesUsedForLocking:(NSArray
*)attributes
- (void)setCachesObjects:(BOOL)flag
See Also: - cachesObjects
- (void)setClassName:(NSString
*)name
An enterprise object class other than EOGenericRecord can be mapped to only one entity.
See Also: - className
- (BOOL)setClassProperties:(NSArray
*)properties
- (void)setExternalName:(NSString
*)name
- (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
- (void)setIsAbstractEntity:(BOOL)flag
- (void)setMaxNumberOfInstancesToBatchFetch:(unsigned
int)size
See Also: - maxNumberOfInstancesToBatchFetch
- (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:
- (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:
- (void)setReadOnly:(BOOL)flag
See Also: - isReadOnly
- (void)setRestrictingQualifier:(EOQualifier
*)aQualifier
- (void)setSharedObjectFetchSpecificationsByName:(NSArray
*)names
- (void)setStoredProcedure:(EOStoredProcedure
*)storedProcedure
forOperation:(NSString *)operation
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:
- (void)setUserInfo:(NSDictionary
*)dictionary
- (NSArray *)sharedObjectFetchSpecificationNames
- (EOStoredProcedure *)storedProcedureForOperation:(NSString
*)operation
See Also: - setStoredProcedure:forOperation:, - parameterDirection (EOAttribute), - storedProcedure (EOAttribute)
- (NSArray *)subEntities
See Also: - addSubEntity:, - parentEntity, - removeSubEntity:
- (NSDictionary *)userInfo
See Also: - setUserInfo:
- (NSException *)validateName:(NSString
*)name
setName: uses this method to validate its argument.