|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eoaccess.EOEntity
public class EOEntity
An EOEntity describes a table in a database and associates a name internal to the Enterprise Objects 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.
You usually define entities in an EOModel using the EOModeler application. EOEntity objects are primarily used by the Enterprise Objects Framework for mapping tables in the database to Enterprise Objects in the application. You are not likely to interact with them directly unless you are 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 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
method.
Like the other major modeling classes, EOEntity provides a user dictionary for the application to store any application-specific information related to the entity.
Note that if an entity has no Enterprise Object class name, the database-level objects use EOGenericRecord.
EOEntity.setStoredProcedure(EOStoredProcedure storedProcedure, String operation)
,
EOAttribute
,
EORelationship
,
EOGenericRecord
Field Summary | |
---|---|
static String |
DeleteProcedureOperation
A stored procedure to delete a row. |
static String |
FetchAllProcedureOperation
A stored procedure to fetch all records. |
static String |
FetchWithPrimaryKeyProcedureOperation
A stored procedure to fetch by primary key. |
static String |
InsertProcedureOperation
A stored procedure to insert a row. |
static String |
NextPrimaryKeyProcedureOperation
A stored procedure to generate a new primary key. |
Constructor Summary | |
---|---|
EOEntity()
Creates and returns a new EOEntity. |
|
EOEntity(NSDictionary plist,
Object owner)
Creates and returns a new EOEntity initialized from the property list plist belonging to the EOModel owner . |
Method Summary | |
---|---|
void |
addAttribute(EOAttribute attribute)
Adds attribute to the receiver and sets the receiver as the attribute's entity. |
void |
addFetchSpecification(EOFetchSpecification fetchSpec,
String name)
Adds the fetch specification fetchSpec to the receiver and associates name with it. |
void |
addIndex(EOEntityIndex index)
Adds index to the receiver and sets the receiver as the index's entity.\ |
void |
addRelationship(EORelationship relationship)
Adds relationship to the receiver and sets the receiver as the relationship's entity. |
void |
addSharedObjectFetchSpecificationByName(String name)
Adds the fetch specification identified by name to the set of fetch specifications used to load objects into a shared editing context. |
void |
addSubEntity(EOEntity child)
Adds the EOEntity child as a sub-entity of the receiver. |
EOAttribute |
anyAttributeNamed(String name)
Returns the user-created attribute identified by name . |
EORelationship |
anyRelationshipNamed(String relationshipName)
Returns the user-created relationship identified by relationshipName . |
EOAttribute |
attributeNamed(String attributeName)
Returns the attribute named attributeName , or null if no such attribute exists in the receiver. |
NSArray |
attributes()
Returns an array containing all of the receiver's attributes, or an empty array if the receiver has no attributes. |
NSArray |
attributesToFetch()
Returns an array of the EOAttributes that need to be fetched so that they can be included in the row snapshot. |
NSArray |
attributesUsedForLocking()
Returns an array containing those attributes used for locking, that is, those properties whose values must match a snapshot any time a row is updated. |
void |
awakeWithPropertyList(NSDictionary pl)
EOEntity's implementation of this method does nothing. |
void |
beautifyName()
Makes the receiver's name conform to a standard convention. |
boolean |
cachesObjects()
Returns true if all of the objects from the receiver are to be cached in memory and queries are to be evaluated in memory using this cache rather than in the database. |
EOClassDescription |
classDescriptionForInstances()
Returns the EOClassDescription associated with the receiver. |
String |
className()
Returns the name of the Enterprise Object class associated with the receiver. |
String |
classNameWithoutPackage()
Return the name of the Enterprise Object class associated with the receiver without the package information. |
String |
classPackageName()
Return the package of the Enterprise Object class associated with the receive. |
NSArray |
classProperties()
Returns an array containing the properties that are bound to the receiver's class (so that values corresponding to those properties are passed to instances of that class). |
NSArray |
classPropertyNames()
Returns an array containing the names of those properties that are bound to the receiver's class (so that values corresponding to those properties are passed to instances of that class). |
String |
clientClassName()
Returns the name of the client-side Enterprise Object class associated with the receiver. |
NSArray |
clientClassProperties()
Returns an array containing the properties that are bound to the client-side class corresponding to the receiver. |
NSArray |
clientClassPropertyNames()
Returns an array containing the names of the properties that are bound to the client-side class corresponding to the entity. |
void |
encodeIntoPropertyList(NSMutableDictionary result)
Encodes the receiver as a property list. |
NSArray |
externalModelsReferenced()
Examines each of the receiver's relationships and returns a list of all external models referenced by the receiver, or an empty arrray if no external models are referenced. |
String |
externalName()
Returns the name of the receiver as understood by the database server, that is, the receiver's external name. |
static String |
externalNameForInternalName(String internalName,
String separatorString,
boolean allCaps)
Used by the Enterprise Objects Framework to convert an internal object name, internalName to a database schema name that conforms to a standard convention, separating name elements with separatorString and capitalizing or lowercasing the external name based on
the Boolean parameter allCaps . |
String |
externalQuery()
Returns a query statement that is used by an EOAdaptorChannel to select rows for the entity when a qualifier is empty, or null if the entity has no external query. |
EOFetchSpecification |
fetchSpecificationNamed(String fetchSpecName)
Returns the fetch specification identified by fetchSpecName . |
NSArray |
fetchSpecificationNames()
Returns an alphabetically sorted array of the names of the receiver's fetch specifications. |
EOGlobalID |
globalIDForRow(NSDictionary row)
Constructs a unique global identifier for the receiver from the keys and values in the dictionary row , which represents a database row. |
boolean |
hasExternalName()
Checks if an entity is not abstract and has a valid external name. |
boolean |
hasRealAttributes()
Checks to see if the enity has real attributes. |
boolean |
hasSimplePrimaryKey()
Check if the entity use a simple primary key (Number) |
NSArray |
indexes()
/** Returns an array containing all of the receiver's indexs, or an empty array if the receiver has no indexes. |
EOEntityIndex |
indexNamed(String indexName)
Returns the index identified by indexName , or null if the receiver has no such index. |
boolean |
isAbstractEntity()
Returns true if the receiver is an abstract entity, false otherwise. |
boolean |
isPrimaryKeyValidInObject(NSKeyValueCoding object)
Returns true if every key attribute is present in object and has a value that is not null . |
boolean |
isQualifierForPrimaryKey(EOQualifier qualifier)
Returns true if qualifier describes the primary key and nothing but the primary key, false otherwise. |
boolean |
isReadOnly()
Returns true if the receiver can not be modified, false if it can. |
boolean |
isSubEntityOf(EOEntity entity)
Checks if the receiving entity is a subentity of entity. |
boolean |
isValidAttributeUsedForLocking(EOAttribute anAttribute)
Returns true if anAttribute can be used for locking, false otherwise. |
boolean |
isValidClassProperty(Object aProp)
Returns true if the property aProp is a valid class property of the receiver, false otherwise. |
boolean |
isValidPrimaryKeyAttribute(EOAttribute anAttribute)
Returns false if anAttribute isn't an EOAttribute, doesn't belong to the entity or is derived. |
int |
maxNumberOfInstancesToBatchFetch()
Returns the maximum number of to-one faults from the receiver to fire at one time. |
EOModel |
model()
Returns the EOModel that contains the receiver. |
String |
name()
Returns the receiver's name. |
static String |
nameForExternalName(String externalName,
String separatorString,
boolean initialCaps)
Used by the Enterprise Objects Framework to convert a database schema name externalName to an internal object name that conforms to a standard convention, using the capitalization rule initialCaps and removing the character separatorString that
separates name elements in the external name. |
EOEntity |
parentEntity()
Returns the parent entity for the receiver, that is, the entity from which the receiver inherits. |
NSArray |
primaryKeyAttributeNames()
Returns an array containing the names of the EOAttributes that make up the receiver's primary key. |
NSArray |
primaryKeyAttributes()
Returns an array of those EOAttributes that make up the receiver's primary key. |
NSDictionary |
primaryKeyForGlobalID(EOGlobalID gid)
Returns the primary key for the object identified by gid , or null if gid is not an instance of EOKeyGlobalID. |
NSDictionary |
primaryKeyForRow(NSDictionary row)
Returns the primary key for row , or null if the primary key can't be computed. |
String |
primaryKeyRootName()
Returns the external name (that is, the name understood by the database) of the receiver's root (parent) entity. |
EOProperty |
propertyNamed(String propertyName)
Returns the property identified by propertyName , or null if the receiver has no such property. |
EOQualifier |
qualifierForPrimaryKey(NSDictionary row)
Returns a qualifier for the receiver that can be used to fetch an instance of the receiver with the primary key extracted from row . |
boolean |
referencesProperty(Object property)
Returns true if any of the receiver's attributes or relationships reference property , false otherwise. |
EORelationship |
relationshipNamed(String relationshipName)
Returns the relationship identified by relationshipName , or null if the receiver has no such relationship. |
NSArray |
relationships()
Returns an array containing all of the receiver's relationships or null if the receiver has none. |
void |
removeAttribute(EOAttribute attribute)
If attribute exists, removes it from the receiver. |
void |
removeFetchSpecificationNamed(String name)
Removes the fetch specification identifed by name from the receiver. |
void |
removeIndex(EOEntityIndex index)
If index exists, removes it from the receiver. |
void |
removeRelationship(EORelationship relationship)
If relationship exists, removes it from the receiver. |
void |
removeSharedObjectFetchSpecificationByName(String name)
Removes the fetch specification identified by name from the set of fetch specifications used to load objects into a shared editing context. |
void |
removeSubEntity(EOEntity child)
Removes the EOEntity child from the list of sub-entities that inherit from the receiver. |
EOQualifier |
restrictingQualifier()
Returns the qualifier used to restrict all queries made against the receiver. |
EOQualifier |
schemaBasedQualifier(EOQualifier qualifier)
Returns an SQL qualifier based on qualifier that is suitable for evaluation by a database (as opposed to in-memory evaluation). |
boolean |
setAttributesUsedForLocking(NSArray attributes)
If all of the the EOAttributes in attributes can be used by an EODatabaseChannel to lock Enterprise Objects for updates, sets attributes as the receiver's attributes used for locking and returns true . |
void |
setCachesObjects(boolean flag)
Based on the Boolean value flag , sets whether the receiver's Enterprise Objects are cached the first time the associated database table is queried. |
void |
setClassName(String name)
Assigns name as the name of the Enterprise Object class associated with the receiver if name is not null . |
boolean |
setClassProperties(NSArray attributes)
If all of the the EOAttributes in attributes are valid class properties of the receiver, sets attributes as the receiver's class properties and returns true . |
void |
setExternalName(String string)
Sets the name of the receiver as understood by the database server (that is, the receiver's external name) to string . |
void |
setExternalQuery(String string)
Assigns string as the query statement used for selecting rows from the entity when there is no qualifier. |
void |
setIsAbstractEntity(boolean flag)
Based on the Boolean flag , sets whether the receiver is an abstract entity, false otherwise. |
void |
setMaxNumberOfInstancesToBatchFetch(int size)
Sets the maximum number of faults from the entity to trigger at one time to size . |
void |
setName(String name)
Sets the receiver's name to name . |
boolean |
setPrimaryKeyAttributes(NSArray attributes)
If all of the the EOAttributes in attributes are valid primary keys of the receiver, sets attributes as the receiver's primary keys and returns true . |
void |
setReadOnly(boolean flag)
Sets whether the receiver is read-only based on the Boolean value flag . |
void |
setRestrictingQualifier(EOQualifier qualifier)
Assigns qualifier as the qualifier used to restrict all queries made against the receiver. |
void |
setSharedObjectFetchSpecificationsByName(NSArray names)
Sets the names of the fetch specifications used to load objects into a shared editing context to names . |
void |
setStoredProcedure(EOStoredProcedure storedProcedure,
String operation)
Sets storedProcedure as a stored procedure for the receiver and associates with it the name operation , which must be one of the following:FetchAllProcedureOperation
FetchWithPrimaryKeyProcedureOperation
InsertProcedureOperation
DeleteProcedureOperation
NextPrimaryKeyProcedureOperation
This information is used when changes from the object graph have been transformed into EODatabaseOperations that are being used to construct EOAdaptorOperations. |
void |
setUserInfo(NSDictionary dictionary)
Sets the dictionary of auxiliary user data to dictionary . |
NSArray |
sharedObjectFetchSpecificationNames()
Returns an array of strings, which are the names of the fetch specifications used to load objects into a shared editing context. |
EOStoredProcedure |
storedProcedureForOperation(String operation)
Returns the stored procedure identified by the name operation , if one has been set. |
NSArray |
subEntities()
Returns a list of those entities that inherit from the receiver, or an empty array if no entities inherit from the receiver. |
String |
toString()
Returns a string representation of all the receiver's properties. |
NSDictionary |
userInfo()
Returns a dictionary of user data. |
String |
valueForSQLExpression(EOSQLExpression context)
Returns an SQL query string based on the receiver's external name and an EOSQLExpression object context . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String FetchAllProcedureOperation
public static final String FetchWithPrimaryKeyProcedureOperation
public static final String InsertProcedureOperation
public static final String DeleteProcedureOperation
public static final String NextPrimaryKeyProcedureOperation
Constructor Detail |
---|
public EOEntity()
public EOEntity(NSDictionary plist, Object owner)
plist
belonging to the EOModel owner
. plist
is dictionary containing only property list data types (that is, NSDictionary, NSArray, NSData, and String). This constructor is used
by EOModeler when it reads in an EOModel from a file.
plist
- A dictionary of property list values from which to initialize the new EOEntity object.owner
- The EOModel to which the newly created entity belongs.EOPropertyListEncoding.encodeIntoPropertyList(NSMutableDictionary propertyList)
,
EOPropertyListEncoding.awakeWithPropertyList(NSDictionary propertyList)
Method Detail |
---|
public String name()
public String toString()
toString
in class Object
public EOModel model()
EOModel.addEntity(EOEntity anEntity)
public String externalName()
public String externalQuery()
null
if the entity has no external query. An empty qualifier is one that specifies only the entity and would thus fetch all Enterprise Objects for that
entity.
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.
null
.EOEntity.setExternalQuery(String name)
,
EOStoredProcedure
public EOQualifier restrictingQualifier()
For example, if you are using the "single table" inheritance model in which parent and child data are contained in the same table, you would 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.
EOEntity.setRestrictingQualifier(EOQualifier aQualifier)
public boolean isReadOnly()
true
if the receiver can not be modified, false
if it can. If an entity is read-only, then Enterprise Objects fetched for that entity are also read-only (that is, can not be inserted, deleted, or updated).
true
if the entity can't be modified.public boolean cachesObjects()
true
if all of the objects from the receiver are to be cached in memory and queries are to be evaluated in memory using this cache rather than in the database. This method should only be used for fairly small tables of read-only objects, since the first access to the
entity will trigger fetching the entire table. You should generally restrict this method to read-only entities to avoid cached data becoming out of sync with database data. Also, you shouldn't use this method if the application will be making any queries against the entity that can't be
evaluated in memory.
invalidateResultCachedForEntityNamed(String name)
.
true
if all of the objects from the receiver are to be cached in memory.EOEntity.setCachesObjects(boolean flag)
,
invalidateResultCachedForEntityNamed(String name)
public NSArray sharedObjectFetchSpecificationNames()
public String classNameWithoutPackage()
EOEntity.className()
public String classPackageName()
EOEntity.className()
public String className()
public EOQualifier qualifierForPrimaryKey(NSDictionary row)
row
. Throws an exception if the value of the primary key obtained from row
is either null
or
NSKeyValueCoding.NullValue
.
row
- A primary key dictionary for a row in the database.
row
.
IllegalArgumentException
- if the primary key is null
or NSKeyValueCoding.NullValue
.EOEntity.isQualifierForPrimaryKey(EOQualifier aQualifier)
,
EOEntity.restrictingQualifier()
public boolean isQualifierForPrimaryKey(EOQualifier qualifier)
true
if qualifier
describes the primary key and nothing but the primary key, false
otherwise. Throws a runtime exception if an error in encountered during evaluation; the error text indicates the nature of the exception.
qualifier
- An EOQualifier object.
true
if qualifier
describes only the primary key.public EOAttribute attributeNamed(String attributeName)
attributeName
, or null
if no such attribute exists in the receiver.
attributeName
- The name of an attribute.
null
.EOEntity.anyAttributeNamed(String attributeName)
,
EOEntity.attributes()
,
EOEntity.relationshipNamed(String name)
public NSArray attributes()
EOEntity.anyAttributeNamed(String attributeName)
,
EOEntity.attributeNamed(String attributeName)
public NSArray indexes()
EOEntity.indexNamed(String indexName)
public EOEntityIndex indexNamed(String indexName)
indexName
, or null
if the receiver has no such index.
indexName
- The name of a relationship.
null
.EOEntity.indexes()
public EORelationship relationshipNamed(String relationshipName)
relationshipName
, or null
if the receiver has no such relationship.
relationshipName
- The name of a relationship.
null
.EOEntity.anyRelationshipNamed(String relationshipName)
,
EOEntity.attributeNamed(String attributeName)
,
EOEntity.relationships()
public EOProperty propertyNamed(String propertyName)
propertyName
, or null
if the receiver has no such property.
propertyName
- The name of a property.
null
.public EORelationship anyRelationshipNamed(String relationshipName)
relationshipName
. If none exists, this method looks through the "hidden" relationships created by the Enterprise Objects Framework for one with the given name. If none is found, null
is returned.
relationshipName
- The name of a relationship.
null
.EOEntity.relationshipNamed(String name)
,
EOEntity.relationships()
public EOAttribute anyAttributeNamed(String name)
name
. If no such attribute exists, this method looks through the "hidden" attributes created by the Enterprise Objects Framework for one with the given name. Hidden attributes are used for such things as primary keys on target
entities of flattened attributes. Returns null
if no attribute with the given name is found.
name
- The name of an attribute.
name
, or null
.EOEntity.attributeNamed(String attributeName)
,
EOEntity.attributes()
public NSArray fetchSpecificationNames()
EOEntity.addFetchSpecification(EOFetchSpecification fetchSpec, String fetchSpecName)
,
EOEntity.fetchSpecificationNamed(String fetchSpecName)
,
EOEntity.removeFetchSpecificationNamed(String fetchSpecName)
public EOFetchSpecification fetchSpecificationNamed(String fetchSpecName)
fetchSpecName
.
fetchSpecName
- The name of a fetch specification.
fetchSpecName
.EOEntity.addFetchSpecification(EOFetchSpecification fetchSpec, String fetchSpecName)
,
EOEntity.fetchSpecificationNames()
,
EOEntity.removeFetchSpecificationNamed(String fetchSpecName)
public NSArray relationships()
null
if the receiver has none. Throws a runtime exception if an error is encountered during processing; the error text indicates the nature of the exception.
null
.EOEntity.attributes()
public NSArray classProperties()
EOEntity.classPropertyNames()
public NSArray classPropertyNames()
EOEntity.classProperties()
public String clientClassName()
Equivalent to the EOAccessAdditions method clientClassNameForEntity
in the EOJavaClient Framework in WebObjects 4.5.x.
public NSArray clientClassProperties()
Equivalent to the EOAccessAdditions method clientClassPropertiesForEntity
in the EOJavaClient Framework in WebObjects 4.5.x.
public NSArray clientClassPropertyNames()
Equivalent to the EOAccessAdditions method clientClassPropertyNamesForEntity
in the EOJavaClient Framework in WebObjects 4.5.x.
public NSArray attributesToFetch()
public NSArray primaryKeyAttributes()
EOEntity.primaryKeyAttributeNames()
public NSArray primaryKeyAttributeNames()
EOEntity.primaryKeyAttributes()
public NSArray attributesUsedForLocking()
EODatabaseContext
public NSDictionary primaryKeyForRow(NSDictionary row)
row
, or null
if the primary key can't be computed. The primary key is a dictionary whose keys are attribute names and whose values are values for those attributes.
row
- The dictionary of keys and values representing a database row.
row
, or null
.EOEntity.primaryKeyForGlobalID(EOGlobalID gid)
public boolean isValidAttributeUsedForLocking(EOAttribute anAttribute)
true
if anAttribute
can be used for locking, false
otherwise. In order for an attribute to be valid for locking, it must be an attribute belonging to the receiver and must not be a derived attribute. Used to test the validity of an
attribute for locking before passing it to setAttributesUsedForLocking
.
anAttribute
- An EOAttribute.
true
if the attribute can be used for locking.EOEntity.attributesUsedForLocking()
,
EOEntity.setAttributesUsedForLocking(NSArray attributes)
public boolean isValidPrimaryKeyAttribute(EOAttribute anAttribute)
false
if anAttribute
isn't an EOAttribute, doesn't belong to the entity or is derived. Otherwise returns true
.
anAttribute
- the attribute to query
false
if anAttribute
isn't an EOAttribute, doesn't belong to the entity, or is derived.EOEntity.setPrimaryKeyAttributes(NSArray keys)
public boolean isPrimaryKeyValidInObject(NSKeyValueCoding object)
true
if every key attribute is present in object
and has a value that is not null
. Returns false
otherwise. This method uses the EOKeyValueCoding interface so the object
parameter may be a dictionary instead
of an Enterprise Object.
object
- The object to query.
true
if every key attribute in object
is valid.EOEntity.primaryKeyForRow(NSDictionary aRow)
public boolean isValidClassProperty(Object aProp)
true
if the property aProp
is a valid class property of the receiver, false
otherwise. To be a valid class property, a property must be an instance of EOAttribute or EORelationship.
Note that this method does not tell you whether aProp
is a member of the array returned by the classProperties
method. In other words, unlike classProperties
, classPropertyNames
, and setClassProperties
, this method
does not interact with the properties bound to the receiver's Enterprise Object class.
aProp
- The property to query.
true
if aProp
is a valid class property of the receiver.EOEntity.classProperties()
,
EOEntity.classPropertyNames()
,
EOEntity.setClassProperties(NSArray attributes)
public NSDictionary userInfo()
EOEntity.setUserInfo(NSDictionary dictionary)
public NSArray subEntities()
EOEntity.addSubEntity(EOEntity child)
,
EOEntity.parentEntity()
,
EOEntity.removeSubEntity(EOEntity child)
public EOEntity parentEntity()
EOEntity.subEntities()
public boolean isAbstractEntity()
true
if the receiver is an abstract entity, false
otherwise. An abstract entity is one that has no corresponding Enterprise Objects in the application. Abstract entities are used to model inheritance relationships. For example, you might have a Person
abstract entity that acts as the parent of Customer and Employee entities. Customer and Employee would inherit certain characteristics from Person (such as name and address attributes). However, though the application might have Customer and Employee objects, it would never have a Person
object.
true
if the receiver is an abstract entity.EOEntity.setIsAbstractEntity(boolean flag)
public int maxNumberOfInstancesToBatchFetch()
EOEntity.setMaxNumberOfInstancesToBatchFetch(int size)
public void encodeIntoPropertyList(NSMutableDictionary result)
encodeIntoPropertyList
in interface EOPropertyListEncoding
result
- A property list representation of the receiver.public void awakeWithPropertyList(NSDictionary pl)
awakeWithPropertyList
in interface EOPropertyListEncoding
pl
- The property list representation of an object.public EOGlobalID globalIDForRow(NSDictionary row)
row
, which represents a database row.
row
- A dictionary representation of a database row from which to create an EOGlobalID for the receiver.
EOEntity.primaryKeyForGlobalID(com.webobjects.eocontrol.EOGlobalID globalID)
public NSDictionary primaryKeyForGlobalID(EOGlobalID gid)
gid
, or null
if gid
is not an instance of EOKeyGlobalID.
gid
- The unique identifier for an Enterprise Object.
gid
or null
.EOEntity.globalIDForRow(NSDictionary row)
public boolean setClassProperties(NSArray attributes)
attributes
are valid class properties of the receiver, sets attributes
as the receiver's class properties and returns true
. Otherwise returns false
and leaves the currently-set class properties for
the receiver unchanged.
attributes
- An array of attributes to set as the receiver's class properties.
true
if attributes
can be set as the receiver's class properties.EOEntity.isValidClassProperty(Object property)
public boolean setPrimaryKeyAttributes(NSArray attributes)
attributes
are valid primary keys of the receiver, sets attributes
as the receiver's primary keys and returns true
. Otherwise returns false
and leaves the currently-set primary keys for the receiver
unchanged.
Primary key attributes should be chosen carefully. Floating-point numbers, for example, can not be reliably compared for equality, and thus are unsuitable for use in primary keys. Integer and string types are the safest choice for primary keys. BigDecimal objects can be used as primary keys, but entail more overhead than integers.
attributes
- An array of attributes to be used as primary keys of the receiver.
true
if attribute
can be set as the receiver's primary key attributes.EOEntity.isValidPrimaryKeyAttribute(EOAttribute anAttribute)
public boolean setAttributesUsedForLocking(NSArray attributes)
attributes
can be used by an EODatabaseChannel to lock Enterprise Objects for updates, sets attributes
as the receiver's attributes used for locking and returns true
. Otherwise returns false
and
leaves the receiver's currently-set attributes used for locking unchanged.
attributes
- An array of attributes to be used for locking on the receiver.
true
if attributes
can be set as the receiver's attributes used for locking.EOEntity.isValidAttributeUsedForLocking(EOAttribute anAttribute)
,
EODatabase
,
EODatabaseContext
,
EODatabaseChannel
public void setName(String name)
name
.
name
- The name to set for the receiver.EOEntity.beautifyName()
public void setExternalName(String string)
string
. For example, though the application may know the receiver as "JobTitle", the database may require a form such as "JOB_TTL".
An adaptor uses the external name to communicate with the database; the application should never need to use the external name.
string
- The external (database server) name for the receiver.public void setExternalQuery(String string)
string
as the query statement used for selecting rows from the entity when there is no qualifier. 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.
An external query is sent unaltered to the database server, and so must contain the external (column) names instead of the entity's attribute names. However, to work properly with the adaptor, the external query must use the columns in alphabetical order by their corresponding EOAttributes' names.
string
- The query text.EOEntity.externalQuery()
,
EOStoredProcedure
,
EOAttribute.columnName()
public void setRestrictingQualifier(EOQualifier qualifier)
qualifier
as the qualifier used to restrict all queries made against the receiver. The restricting qualifier can be used to map an entity to a subset of the rows in a table.
qualifier
- An EOQualifier used to restrict all queries for the receiver.EOEntity.restrictingQualifier()
public void setReadOnly(boolean flag)
flag
. If an entity is read-only, the database rows for that entity can not be modified by the application.
flag
- Boolean value to set whether the receiver is read-only.EOEntity.isReadOnly()
public void setCachesObjects(boolean flag)
flag
, sets whether the receiver's Enterprise Objects are cached the first time the associated database table is queried.
invalidateResultCacheForEntityNamed(String name)
.
flag
- Boolean value to set whether the receiver's fetched objects are cached.invalidateResultCacheForEntityNamed(String name)
,
EOEntity.cachesObjects()
public void setSharedObjectFetchSpecificationsByName(NSArray names)
names
.
names
- An array of names of fetch specifications.public void addSharedObjectFetchSpecificationByName(String name)
name
to the set of fetch specifications used to load objects into a shared editing context.
name
- The name of a fetch specification to add to the receiver's list of shared object fetch specifications.public void removeSharedObjectFetchSpecificationByName(String name)
name
from the set of fetch specifications used to load objects into a shared editing context.
name
- The name of a fetch specification to remove from the receiver's list of shared object fetch specifications.public void addAttribute(EOAttribute attribute)
attribute
to the receiver and sets the receiver as the attribute's entity. Throws an exception if: attribute
is null
.attribute
has an EOEntity set that is different than the receiver.attribute
's name is already in use by another attribute or relationship belonging to the receiver.
attribute
- A attribute to add to the receiver.
IllegalArgumentException
- if attribute
's name is null
or is already in use by another attribute or relationship; or if attribute
has a different entity already set.
RuntimeException
- if an error is encountered during processing; the error text indicates the nature of the exception.EOEntity.removeAttribute(EOAttribute name)
,
EOEntity.attributes()
,
EOEntity.attributeNamed(String attributeName)
public void removeAttribute(EOAttribute attribute)
attribute
exists, removes it from the receiver. Always use referencesProperty
to check that an attribute isn't referenced by another property before removing it.
attribute
- An existing attribute of the receiver.EOEntity.addAttribute(EOAttribute anAttribute)
,
EOEntity.attributes()
,
EOEntity.referencesProperty(Object property)
public void addRelationship(EORelationship relationship)
relationship
to the receiver and sets the receiver as the relationship's entity. Throws an exception if: relationship
is null
.relationship
has an EOEntity set that is different than the receiver.relationship
's name is already in use by another attribute or relationship belonging to the receiver.
relationship
- A relationship to add to the receiver.
IllegalArgumentException
- if relationship
's name is null
or is already in use by another attribute or relationship; or if relationship
has a different entity already set.
RuntimeException
- if an error is encountered during processing; the error text indicates the nature of the exception.EOEntity.removeRelationship(EORelationship name)
,
EOEntity.relationships()
,
EOEntity.relationshipNamed(String name)
public void removeRelationship(EORelationship relationship)
relationship
exists, removes it from the receiver. Always use referencesProperty
to check that a relationship isn't referenced by another property before removing it.
relationship
- The relationship to remove from the receiver.EOEntity.addRelationship(EORelationship aRelationship)
,
EOEntity.relationships()
,
EOEntity.referencesProperty(Object property)
public void addIndex(EOEntityIndex index)
index
to the receiver and sets the receiver as the index's entity.\
index
- public void removeIndex(EOEntityIndex index)
index
exists, removes it from the receiver.
index
- The index to remove from the receiver.EOEntity.addRelationship(EORelationship aRelationship)
,
EOEntity.relationships()
,
EOEntity.referencesProperty(Object property)
public void addFetchSpecification(EOFetchSpecification fetchSpec, String name)
fetchSpec
to the receiver and associates name
with it. Throws an exception if the entityName
for fetchSpec
is different than the receiver's name.
fetchSpec
- A fetch specification.name
- A name for fetchSpec
.EOEntity.fetchSpecificationNamed(String fetchSpecName)
,
EOEntity.fetchSpecificationNames()
,
EOEntity.removeFetchSpecificationNamed(String fetchSpecName)
public void removeFetchSpecificationNamed(String name)
name
from the receiver.
name
- The name of a fetch specification to remove.EOEntity.addFetchSpecification(EOFetchSpecification fetchSpec, String fetchSpecName)
,
EOEntity.fetchSpecificationNamed(String fetchSpecName)
,
EOEntity.fetchSpecificationNames()
public void setClassName(String name)
name
as the name of the Enterprise Object class associated with the receiver if name
is not null
. The specified class need not be present in the runtime system when this message is sent. When an EODatabaseChannel fetches objects for the
receiver, they are created as instances of this class. The application may have to load the class on demand if it isn't present in the runtime system; if it doesn't load the class, EOGenericRecord will be used.
An Enterprise Object class other than EOGenericRecord can be mapped to only one entity.
name
- The name of the enteprise object class associated with the receiver.EOEntity.className()
public void setUserInfo(NSDictionary dictionary)
dictionary
. The userInfo dictionary contains arbitrary data that the application can use for whatever it needs. dictionary
can only contain property list data types: String, NSDictionary, NSArray, and NSData.
dictionary
- Arbitrary information for use by the application.public void addSubEntity(EOEntity child)
child
as a sub-entity of the receiver. This is the first step in setting up an inheritance hierarchy between entities.
NOTE: addSubEntity
and removeSubEntity
are not thread-safe. In general, modifying an EOModel programmatically is not thread-safe.
child
- An EOEntity which will inherit from the receiver.EOEntity.subEntities()
,
EOEntity.removeSubEntity(EOEntity child)
public void removeSubEntity(EOEntity child)
child
from the list of sub-entities that inherit from the receiver.
NOTE: addSubEntity
and removeSubEntity
are not thread-safe. In general, modifying an EOModel programmatically is not thread-safe.
child
- An EOEntity to remove from the receiver's list of sub-entities.EOEntity.addSubEntity(EOEntity child)
,
EOEntity.subEntities()
public void setIsAbstractEntity(boolean flag)
flag
, sets whether the receiver is an abstract entity, false
otherwise. Abstract entities are used to model inheritance relationships.
For example, you might have a Person abstract entity that acts as the parent of Customer and Employee entities. Customer and Employee would inherit certain characteristics from Person (such as name and address attributes). However, though the application might have Customer and Employee objects, it would never have a Person object.
flag
- true
if the receiver is an abstract entity.EOEntity.isAbstractEntity()
public void setMaxNumberOfInstancesToBatchFetch(int size)
size
. By default, only one object is fetched from the database when you trigger a fault.
Using this optional method to fetch a batch of faults when one fault is triggered helps to optimize performance by getting extra work done for each round trip to the database.
size
- The maximum number of faults to trigger at one time.EOEntity.maxNumberOfInstancesToBatchFetch()
public void beautifyName()
EOEntity.setName(String name)
,
EOModel.beautifyNames()
public EOClassDescription classDescriptionForInstances()
EOClassDescription
,
EOEntity
public boolean referencesProperty(Object property)
true
if any of the receiver's attributes or relationships reference property
, false
otherwise. A property can be referenced by a flattened attribute or by a relationship.
For example, suppose a model has an Employee entity with a toDepartment
relationship. If you flatten the department's name attribute into the Employee entity, creating a departmentName
attribute, that flattened attribute references the toDepartment
relationship. If an entity has any outstanding references to a property, you shouldn't remove the property.
property
- An attribute or relationship of the receiver.
true
if any of the receiver's attributes or relationships reference property
.EOEntity.removeAttribute(EOAttribute name)
,
EOEntity.removeRelationship(EORelationship name)
public NSArray externalModelsReferenced()
EOEntity.referencesProperty(Object property)
public String valueForSQLExpression(EOSQLExpression context)
context
. Returns the receiver's external name if context
is null
.
For conformance to the EOSQLExpression.SQLValue interface.
valueForSQLExpression
in interface EOSQLExpression.SQLValue
context
- An EOSQLExpression object.
context
, or the receiver's external name.EOEntity.externalName()
,
EOSQLExpression
public boolean isSubEntityOf(EOEntity entity)
entity
-
public EOStoredProcedure storedProcedureForOperation(String operation)
operation
, if one has been set. Otherwise, returns null
. operation
must be one of the following: FetchAllProcedureOperation
FetchWithPrimaryKeyProcedureOperation
InsertProcedureOperation
DeleteProcedureOperation
NextPrimaryKeyProcedureOperation
operation
- The name of a stored procedure.
operation
, or null
.EOEntity.FetchAllProcedureOperation
,
EOEntity.FetchWithPrimaryKeyProcedureOperation
,
EOEntity.InsertProcedureOperation
,
EOEntity.DeleteProcedureOperation
,
EOEntity.NextPrimaryKeyProcedureOperation
,
EOEntity.setStoredProcedure(EOStoredProcedure storedProcedure , String operation)
,
EOAttribute.parameterDirection()
,
EOAttribute.storedProcedure()
public void setStoredProcedure(EOStoredProcedure storedProcedure, String operation)
storedProcedure
as a stored procedure for the receiver and associates with it the name operation
, which must be one of the following:FetchAllProcedureOperation
FetchWithPrimaryKeyProcedureOperation
InsertProcedureOperation
DeleteProcedureOperation
NextPrimaryKeyProcedureOperation
storedProcedure
- A stored procedure for the operation described by the name operation
.operation
- The name of an EODatabaseOperation.EOEntity.FetchAllProcedureOperation
,
EOEntity.FetchWithPrimaryKeyProcedureOperation
,
EOEntity.InsertProcedureOperation
,
EOEntity.DeleteProcedureOperation
,
EOEntity.NextPrimaryKeyProcedureOperation
,
EOEntity.storedProcedureForOperation(String operation)
,
EOStoredProcedure
public String primaryKeyRootName()
EOEntity.externalName()
,
EOEntity.name()
,
EOEntity.parentEntity()
public boolean hasExternalName()
public boolean hasRealAttributes()
public boolean hasSimplePrimaryKey()
public static String externalNameForInternalName(String internalName, String separatorString, boolean allCaps)
internalName
to a database schema name that conforms to a standard convention, separating name elements with separatorString
and capitalizing or lowercasing the external name based on
the Boolean parameter allCaps
.
By default, the separator string is an underscore and full capitalization is turned on. Consequently "name" becomes "NAME" and "firstName" becomes "FIRST_NAME". If allCaps
is false
, this method converts "firstName" to "first_name". A different separator string
may also be specified.
internalName
- An internal object model name.separatorString
- A character that is used to separate name elements.allCaps
- Boolean flag to determine whether to capitalize the returned external name.
internalName
, separatorString
, and allCaps
.EOEntity.nameForExternalName(String externalName, String separatorString, boolean initialCaps)
public static String nameForExternalName(String externalName, String separatorString, boolean initialCaps)
externalName
to an internal object name that conforms to a standard convention, using the capitalization rule initialCaps
and removing the character separatorString
that
separates name elements in the external name.
By default, the separator string is assumed to be an underscore, however a different character may be specified, as used by the database. The default capitalization rule for EOAttribute, EORelationship, or EOStored procedure object names is false
, that is, all lower-case
except for the initial letter of each embedded word other than the first, which is upper-case. Consequently, "NAME" becomes "name" and "FIRST_NAME" becomes "firstName".
The default capitalization rule for EOEntity object names is true
, that is, is all lower-case except for the initial letter of each word. Consequently "CUSTOMER_ACCOUNT" becomes "CustomerAccount".
externalName
- A table or column name in the database schema.separatorString
- A character that is used to separate name elements in the externalName
.initialCaps
- Boolean flag to determine whether to capitalize the initial letter of every name element.
externalName
, separatorString
, and initialCaps
.EOEntity.externalNameForInternalName(String internalName, String separatorString, boolean allCaps)
,
EOEntity.beautifyName()
,
EOModel.beautifyNames()
,
EOAttribute.beautifyName()
,
EORelationship.beautifyName()
,
EOStoredProcedure.beautifyName()
public EOQualifier schemaBasedQualifier(EOQualifier qualifier)
qualifier
that is suitable for evaluation by a database (as opposed to in-memory evaluation). Invoked by an EODatabaseChannel object before it uses its EOAdaptorChannel to perform a database operation. Whereas in-memory qualifier evaluation
uses object instance variables to resolve relationships, a database qualifier must use foreign keys.
qualifier
- A qualifier for in-memory evaluation from which to derive an SQL qualifier for evaluation by the database.
qualifier
that uses foreign keys to resolve relationships.EOQualifierEvaluation
,
EODatabaseChannel.selectObjectsWithFetchSpecification( EOFetchSpecification fetchSpecification, EOEditingContext context)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |