Inherits From:
NSObject
Declared in: EOAccess/EOUtilities.h
Class Description
EOUtilities is a collection of convenience methods intended to make common operations with EOF easier. EOUtilities is an EOAccess class that consists entirely of static methods-you never instantiate an EOUtilities object.
Each method requires an editing context into which the objects should be fetched; this editing context is passed as the first argument to each method in EOUtilities.
Note:
The Objective-C source code for EOUtilities is available as an example. On Mac OS X Server
systems, see /System/Developer/Examples/EnterpriseObjects/Sources/EOUtilities
. On NT, see
$NEXT_ROOT\Developer\Examples\EnterpriseObjects\Sources\EOUtilities
.
connectWithModelNamed
public static void connectWithModelNamed
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String modelName,
NSDictionary overrides)
Connects to the database using the connection information in the specified model and the provided overrides dictionary. This method facilitates per-session database logins in WebObjects applications. Typically, you'd put a login name and password in the overrides dictionary and otherwise use the values in the model's connection dictionary. Throws an exception if the connection failed.
databaseContextForModelNamed
public static EODatabaseContext databaseContextForModelNamed
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName)
Returns the database context used to service the specified model.
destinationKeyForSourceObject
public static NSDictionary destinationKeyForSourceObject
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.Object object,
java.lang.String entityName)
Returns the foreign key for the rows at the destination entity of the specified relationship. As an example, given entities Department and Employee with a relationship called "department" joining Department.ID Employee.deptID
, invoking this method on a Department object with ID equal to 5 will return a dictionary with a value of 5 for the deptID key.
See also:
primaryKeyForObject
entityForClass
public static EOEntity entityForClass
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.Class classObject)
Returns the entity associated with the specified class. Throws an exception if the specified entity can't be found or if more than one entity is associated with the class.
See also:
entityForObject
, entityNamed
, objectsOfClass
entityForObject
public static EOEntity entityForObject
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.Object object)
Returns the entity associated with the provided enterprise object. Throws an exception if the specified entity can't be found.
See also:
entityForClass
, entityNamed
entityNamed
public static EOEntity entityNamed
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName)
Returns the entity with the specified name. Throws an exception if the specified entity can't be found.
See also:
entityForClass
, entityForObject
executeStoredProcedureNamed
public static NSDictionary executeStoredProcedureNamed
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String storedProcedureName,
NSDictionary arguments)
Executes the specified stored procedure with the provided arguments. Returns the stored procedure's return values (if any). Use only with stored procedures that don't return results rows.
See also:
rawRowsWithStoredProcedureNamed
localInstanceOfObject
public static java.lang.Object localInstanceOfObject
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.Object object)
Translates the specified enterprise object from another editing context to the specified one.
See also:
localInstancesOfObjects
localInstancesOfObjects
public static NSArray localInstancesOfObjects
(
com.apple.yellow.eocontrol.EOEditingContext, editingContext,
NSArray objects)
Translates the specified enterprise objects from another editing context to the specified one.
See also:
localInstanceOfObject
modelGroup
public static EOModelGroup modelGroup
(
com.apple.yellow.eocontrol.EOEditingContext editingContext)
Returns the model group associated with the editing context's root object store, an EOObjectStoreCoordinator.
objectWithQualifierFormat
public static java.lang.Object objectWithQualifierFormat
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
java.lang.String format,
NSArray arguments)
Creates a qualifier with the provided format string and arguments, and returns matching enterprise objects. Throws an exception unless exactly one object is retrieved.
See also:
objectsWithQualifierFormat
, rawRowsWithQualifierFormat
objectFromRawRow
public static java.lang.Object objectFromRawRow
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
NSDictionary row)
Fetches and returns the object corresponding to the specified raw row (using EOEditingContext's faultForRawRow). This method can only be used on raw rows that include the row's primary key.
objectMatchingKeyAndValue
public static java.lang.Object objectMatchingKeyAndValue
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
java.lang.Object value,
java.lang.String key)
Creates an EOKeyValueQualifier with the specified key and value and returns matching enterprise objects. Throws an exception unless exactly one object is retrieved.
See also:
objectMatchingValues
, objectsMatchingKeyAndValue
objectMatchingValues
public static java.lang.Object objectMatchingValues
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
NSDictionary values)
Creates EOKeyValueQualifiers for each key-value pair in the specified dictionary, ANDs these qualifiers together into an EOAndQualifier, and returns matching enterprise objects. Throws an exception unless exactly one object is retrieved.
See also:
objectMatchingKeyAndValue
, objectsMatchingValues
objectsForEntityNamed
public static NSArray objectsForEntityNamed
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName)
Fetches and returns the enterprise objects associated with the specified entity.
See also:
objectsWithQualifierFormat
, objectsMatchingKeyAndValue
, objectsMatchingValues
objectsWithQualifierFormat
public static NSArray objectsWithQualifierFormat
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
java.lang.String format,
NSArray arguments)
Creates a qualifier with the provided format string and arguments, and returns matching enterprise objects.
See also:
objectWithQualifierFormat
, objectsForEntityNamed
objectsMatchingKeyAndValue
public static NSArray objectsMatchingKeyAndValue
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
java.lang.String key,
java.lang.Object value)
Creates an EOKeyValueQualifier with the specified key and value and returns matching enterprise objects.
See also:
objectMatchingKeyAndValue
, objectsForEntityNamed
, objectsMatchingValues
objectsMatchingValues
public static NSArray objectsMatchingValues
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
NSDictionary values)
Creates EOKeyValueQualifiers for each key-value pair in the specified dictionary, ANDs these qualifiers together into an EOAndQualifier, and returns matching enterprise objects.
See also:
objectMatchingValues
, objectsForEntityNamed
, objectsMatchingKeyAndValue
objectsOfClass
public static NSArray objectsOfClass
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.Class classObject)
Fetches and returns the enterprise objects associated with the specified class. Throws an exception if more than one entity for the class exists.
See also:
entityForClass
objectsWithFetchSpecificationAndBindings
public static NSArray objectsWithFetchSpecificationAndBindings
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String fetchSpecName,
java.lang.String entityName,
NSDictionary bindings)
Fetches and returns the enterprise objects retrieved with the specified fetch specification and bindings.
See also:
objectWithFetchSpecificationAndBindings
objectWithFetchSpecificationAndBindings
public static java.lang.Object objectWithFetchSpecificationAndBindings
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String fetchSpecName,
java.lang.String entityName,
NSDictionary bindings)
Fetches and returns the enterprise objects retrieved with the specified fetch specification and bindings. Throws an exception unless exactly one object is retrieved.
See also:
objectsWithFetchSpecificationAndBindings
objectWithPrimaryKey
public static java.lang.Object objectWithPrimaryKey
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
NSDictionary keyDictionary)
Fetches and returns the enterprise object identified by the specified primary key dictionary. Throws an exception unless exactly one object is retrieved.
See also:
objectMatchingKeyAndValue
, objectWithPrimaryKeyValue
, primaryKeyForObject
objectWithPrimaryKeyValue
public static java.lang.Object objectWithPrimaryKeyValue
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
java.lang.Object value)
Fetches and returns the enterprise object identified by the specified primary key value. For use only with enterprise objects that have non-compound primary keys. Throws an exception unless exactly one object is retrieved.
See also:
objectsMatchingValues
, objectWithPrimaryKey
primaryKeyForObject
public static NSDictionary primaryKeyForObject
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.Object object)
Returns the primary key dictionary for the specified enterprise object.
See also:
objectWithPrimaryKey
, objectWithPrimaryKeyValue
rawRowsWithQualifierFormat
public static NSArray rawRowsWithQualifierFormat
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
java.lang.String format,
NSArray arguments)
Creates a qualifier for the specified entity and with the specified qualifier format and returns matching raw row dictionaries.
See also:
objectsWithQualifierFormat
, rawRowsForSQL
rawRowsMatchingKeyAndValue
public static NSArray rawRowsMatchingKeyAndValue
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
java.lang.String key,
java.lang.Object value);
Creates an EOKeyValueQualifier with the specified key and value and returns matching raw rows.
See also:
objectMatchingKeyAndValue
, objectsMatchingKeyAndValue
, rawRowsMatchingValues
rawRowsMatchingValues
public static NSArray rawRowsMatchingValues
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String entityName,
NSDictionary values)
Creates EOKeyValueQualifiers for each key-value pair in the specified dictionary, ANDs these qualifiers together into an EOAndQualifier, and returns matching raw rows.
See also:
objectMatchingValues
, objectsMatchingValues
, rawRowsMatchingKeyAndValue
rawRowsForSQL
public static NSArray rawRowsForSQL
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String sqlString,
java.lang.String modelName)
Evaluates the specified SQL and returns the resulting raw rows.
See also:
rawRowsWithQualifierFormat
, rawRowsWithStoredProcedureNamed
rawRowsWithStoredProcedureNamed
public static NSArray rawRowsForStoredProcedureNamed
(
com.apple.yellow.eocontrol.EOEditingContext editingContext,
java.lang.String storedProcedureName,
NSDictionary arguments)
Executes the specified stored procedure with the provided arguments and returns the resulting raw rows.
See also:
rawRowsForSQL