Documentation Archive Developer
Search
PATH Documentation > WebObjects

Table of Contents

EOUtilities


Inherits from:
Object
Package:
com.webobjects.eoaccess


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.




Method Types


Creating new objects
createAndInsertInstance
Fetching multiple objects
objectsForEntityNamed
objectsWithQualifierFormat
objectsMatchingKeyAndValue
objectsMatchingValues
objectsOfClass
objectsWithFetchSpecificationAndBindings
Fetching single objects
objectWithQualifierFormat
objectMatchingKeyAndValue
objectMatchingValues
objectWithFetchSpecificationAndBindings
objectWithPrimaryKey
objectWithPrimaryKeyValue
Fetching raw rows
executeStoredProcedureNamed
objectFromRawRow
rawRowsWithQualifierFormat
rawRowsMatchingKeyAndValue
rawRowsMatchingValues
rawRowsForSQL
rawRowsForStoredProcedureNamed
Accessing the EOF stack
connectWithModelNamed
databaseContextForModelNamed
Accessing object data
destinationKeyForSourceObject
localInstanceOfObject
localInstancesOfObjects
primaryKeyForObject
Accessing model information
entityForClass
entityForObject
entityNamed
modelGroup


Static Methods



connectWithModelNamed

public static void connectWithModelNamed( com.webobjects.eocontrol.EOEditingContext editingContext, 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.

createAndInsertInstance

public static com.webobjects.eocontrol.EOEnterpriseObject createAndInsertInstance( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName)

Creates a new enterprise object for the specified entity, inserts it into editingContext, and returns the new object.

databaseContextForModelNamed

public static EODatabaseContext databaseContextForModelNamed( com.webobjects.eocontrol.EOEditingContext editingContext, String modelName)

Returns the database context used to service the specified model.

destinationKeyForSourceObject

public static NSDictionary destinationKeyForSourceObject( com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eocontrol.EOEnterpriseObject object, String relationshipName)

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 and Employee.deptID, invoking this method on a Department object with ID equal to 5 returns a dictionary with a value of 5 for the deptID key.

See Also: primaryKeyForObject



entityForClass

public static EOEntity entityForClass( com.webobjects.eocontrol.EOEditingContext editingContext, 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.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eocontrol.EOEnterpriseObject 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.webobjects.eocontrol.EOEditingContext editingContext, 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.webobjects.eocontrol.EOEditingContext editingContext, 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: rawRowsForStoredProcedureNamed



localInstanceOfObject

public static com.webobjects.eocontrol.EOEnterpriseObject localInstanceOfObject( com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eocontrol.EOEnterpriseObject object)

Translates the specified enterprise object from another editing context to the specified one.

See Also: localInstancesOfObjects



localInstancesOfObjects

public static NSArray localInstancesOfObjects( com.webobjects.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.webobjects.eocontrol.EOEditingContext editingContext)

Returns the model group associated with the editing context's root object store, an EOObjectStoreCoordinator.

objectFromRawRow

public static com.webobjects.eocontrol.EOEnterpriseObject objectFromRawRow( com.webobjects.eocontrol.EOEditingContext editingContext, 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 com.webobjects.eocontrol.EOEnterpriseObject objectMatchingKeyAndValue( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, String key, Object value)

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 com.webobjects.eocontrol.EOEnterpriseObject objectMatchingValues( com.webobjects.eocontrol.EOEditingContext editingContext, 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.webobjects.eocontrol.EOEditingContext editingContext, String entityName)

Fetches and returns the enterprise objects associated with the specified entity.

See Also: objectsWithQualifierFormat, objectsMatchingKeyAndValue, objectsMatchingValues



objectsMatchingKeyAndValue

public static NSArray objectsMatchingKeyAndValue( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, String key, 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.webobjects.eocontrol.EOEditingContext editingContext, 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.webobjects.eocontrol.EOEditingContext editingContext, 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.webobjects.eocontrol.EOEditingContext editingContext, String entityName, String fetchSpecName, NSDictionary bindings)

Fetches and returns the enterprise objects retrieved with the specified fetch specification and bindings.

See Also: objectWithFetchSpecificationAndBindings



objectsWithQualifierFormat

public static NSArray objectsWithQualifierFormat( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, String format, NSArray arguments)

Creates a qualifier with the provided format string and arguments, and returns matching enterprise objects.

See Also: objectWithQualifierFormat, objectsForEntityNamed



objectWithFetchSpecificationAndBindings

public static com.webobjects.eocontrol.EOEnterpriseObject objectWithFetchSpecificationAndBindings( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, String fetchSpecName, 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 com.webobjects.eocontrol.EOEnterpriseObject objectWithPrimaryKey( com.webobjects.eocontrol.EOEditingContext editingContext, 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 com.webobjects.eocontrol.EOEnterpriseObject objectWithPrimaryKeyValue( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, 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



objectWithQualifierFormat

public static com.webobjects.eocontrol.EOEnterpriseObject objectWithQualifierFormat( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, 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



primaryKeyForObject

public static NSDictionary primaryKeyForObject( com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eocontrol.EOEnterpriseObject object)

Returns the primary key dictionary for the specified enterprise object.

See Also: objectWithPrimaryKey, objectWithPrimaryKeyValue



rawRowsForSQL

public static NSArray rawRowsForSQL( com.webobjects.eocontrol.EOEditingContext editingContext, String modelName, String sqlString)

Evaluates the specified SQL and returns the resulting raw rows.

See Also: rawRowsWithQualifierFormat, rawRowsForStoredProcedureNamed



rawRowsForStoredProcedureNamed

public static NSArray rawRowsForStoredProcedureNamed( com.webobjects.eocontrol.EOEditingContext editingContext, String storedProcedureName, NSDictionary arguments)

Executes the specified stored procedure with the provided arguments and returns the resulting raw rows.

See Also: rawRowsForSQL



rawRowsMatchingKeyAndValue

public static NSArray rawRowsMatchingKeyAndValue( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, String key, 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.webobjects.eocontrol.EOEditingContext editingContext, 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



rawRowsWithQualifierFormat

public static NSArray rawRowsWithQualifierFormat( com.webobjects.eocontrol.EOEditingContext editingContext, String entityName, 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



© 2001 Apple Computer, Inc. (Last Published April 13, 2001)


Table of Contents