Inherits from:
Object
Implements:
EOSchemaGeneration,
EOSchemaSynchronization
Package:
com.webobjects.eoaccess
Class Description
This class has been introduced to implement the new interfaces, EOSchemaGeneration and EOSchemaSynchronization. The methods used to be declared and implemented in EOSQLExpression. The 5.0 API is essentially the same. The only difference is that in 4.5 the methods were methods. In 5.0 the methods are instance methods. See the EOSchemaGeneration and EOSchemaSynchronization sections for more information.
Method Types
Constructors
EOSynchronizationFactory
Creating a schema generation script
schemaCreationScriptForEntities
schemaCreationStatementsForEntities
appendExpressionToScript
createTableStatementsForEntityGroup
createTableStatementsForEntityGroups
dropTableStatementsForEntityGroup
dropTableStatementsForEntityGroups
primaryKeyConstraintStatementsForEntityGroup
primaryKeyConstraintStatementsForEntityGroups
primaryKeySupportStatementsForEntityGroup
primaryKeySupportStatementsForEntityGroups
dropPrimaryKeySupportStatementsForEntityGroup
dropPrimaryKeySupportStatementsForEntityGroups
foreignKeyConstraintStatementsForRelationship
createDatabaseStatementsForConnectionDictionary
dropDatabaseStatementsForConnectionDictionary
Synchronizing the database with a model
statementsToUpdateObjectStoreForModel
statementsToUpdateObjectStoreForEntityGroups
statementsToCopyTableNamed
phraseCastingColumnNamed
statementsToRenameTableNamed
statementsToInsertColumnForAttribute
statementsToDeleteColumnNamed
statementsToRenameColumnNamed
statementsToConvertColumnType
isColumnTypeEquivalentToColumnType
statementsToDropForeignKeyConstraintsOnEntityGroups
statementsToDropPrimaryKeyConstraintsOnEntityGroups
statementsToDropPrimaryKeySupportForEntityGroups
statementsToImplementForeignKeyConstraintsOnEntityGroups
statementsToImplementPrimaryKeyConstraintsOnEntityGroups
statementsToImplementPrimaryKeySupportForEntityGroups
Querying about database synchronization support
supportsSchemaSynchronization
supportsDirectColumnCoercion
supportsDirectColumnDeletion
supportsDirectColumnInsertion
supportsDirectColumnNullRuleModification
supportsDirectColumnRenaming
Constructors
public EOSynchronizationFactory(EOAdaptor adaptor)
Description forthcoming.
Instance Methods
public void appendExpressionToScript( EOSQLExpression anSQLExpression, StringBuffer script)
Append's anSQLExpression's statement to script along with any necessary delimiter. EOSQLExpression's implementation appends the SQL statement for anSQLExpression to script followed by a semicolon and a newline. A subclass of EOSQLExpression only needs to override this method if the delimiter for its database server is different. For example, the Oracle and Informix use the default implementation, whereas the Sybase adaptor appends the word "go" instead of a semicolon.
See Also: createTableStatementsForEntityGroup
public NSArray createDatabaseStatementsForConnectionDictionary( NSDictionary connectionDictionary, NSDictionary adminDictionary)
Generates the SQL statements that will create a database (or user, for Oracle) that can be accessed by the provided connection dictionary and administrative connection dictionary.
See Also: dropDatabaseStatementsForConnectionDictionary
public NSArray createTableStatementsForEntityGroup(NSArray entityGroup)
Returns an array of EOSQLExpression objects that define the SQL necessary to create a table for entityGroup, an array of EOEntity objects that have the same externalName. Returns an empty array if entityGroup is null or empty.
EOSQLExpression's implementation does the following:
- Creates an EOSQLExpression object.
- Sets the expression's entity to the first entity in entityGroup.
- Adds a create clause for each Attribute in entityGroup's Entities.
- Sets the expression's statement to CREATE TABLE TABLE_NAME (LIST_STRING), where TABLE_NAME is the externalName of the Entity objects in entityGroup and LIST_STRING is the expression's listString.
- Adds the expression to an array.
- Returns the array.
The following is an example of a CREATE TABLE statement produced by the default implementation:
create table EMPLOYEE (
EMP_ID int not null,
DEPT_ID int null,
LAST_NAME varchar(40) not null,
PHONE char(12) null,
HIRE_DATE date null,
SALARY number(7, 2) null
)
If a subclass's database server's table creation semantics are different, the subclass should override this method or one or more of the following methods as appropriate:
- addCreateClauseForAttribute
- columnTypeStringForAttribute
- allowsNullClauseForConstraint
See Also: createTableStatementsForEntityGroup, dropTableStatementsForEntityGroup
public NSArray createTableStatementsForEntityGroups(NSArray entityGroups)
Returns an array of EOSQLExpression objects that define the SQL necessary to create the tables specified in entityGroups. An entity group is an array of Entity objects that have the same externalName, and entityGroups is an array of entity groups. Returns an empty array if entityGroups is null
or empty. EOSQLExpression's implementation invokes createTableStatementsForEntityGroup for each entity group in entityGroups and returns an array of all the resulting EOSQLExpressions.
See Also: schemaCreationStatementsForEntities
public NSArray dropDatabaseStatementsForConnectionDictionary( NSDictionary connectionDictionary, NSDictionary adminDictionary)
Generates the SQL statements to drop a database (or user, for Oracle).
See Also: createDatabaseStatementsForConnectionDictionary
public NSArray dropPrimaryKeySupportStatementsForEntityGroup(NSArray entityGroup)
Returns an array of EOSQLExpression objects that define the SQL necessary to drop the primary key generation support for entityGroup, an array of Entity objects that have the same externalName. The drop statement generated by this method should be sufficient to remove the primary key support created by primaryKeySupportStatementsForEntityGroup's statements.
EOSQLExpression's implementation creates a statement of the following form:
drop sequence SEQUENCE_NAME
Where SEQUENCE_NAME is the primaryKeyRootName for the first entity in entityGroup concatenated with "_SEQ" (EMP_ID_SEQ, for example).
If a subclass uses a different primary key generation mechanism or if the subclass's database server's drop semantics are different, the subclass should override this method.
public NSArray dropPrimaryKeySupportStatementsForEntityGroups(NSArray entityGroups)
Returns an array of EOSQLExpression objects that define the SQL necessary to drop the primary key generation support for the entities specified in entityGroups. An entity group is an array of EOEntity objects that have the same externalName, and entityGroups is an array of entity groups. EOSQLExpression's implementation invokes dropPrimaryKeySupportStatementsForEntityGroup for each entity group in entityGroups and returns an array of all the resulting EOSQLExpressions.
See Also: schemaCreationStatementsForEntities
public NSArray dropTableStatementsForEntityGroup(NSArray entityGroup)
Returns an array of EOSQLExpression objects that define the SQL necessary to drop the table identified by entityGroup, an array of Entity objects that have the same externalName. The drop statement generated by this method should be sufficient to remove the table created by createTableStatementsForEntityGroup's statements.
EOSQLExpression's implementation creates a statement of the following form:
DROP TABLE TABLE_NAME
Where TABLE_NAME is the externalName of the first entity in entityGroup.
If a subclass's database server's drop semantics are different, the subclass should override this method.
public NSArray dropTableStatementsForEntityGroups(NSArray entityGroups)
Returns an array of EOSQLExpression objects that define the SQL necessary to drop the tables for entityGroups. An entity group is an array of Entity objects that have the same externalName, and entityGroups is an array of entity groups. EOSQLExpression's implementation invokes dropTableStatementsForEntityGroup for each entity group in entityGroups and returns an array of all the resulting EOSQLExpressions.
See Also: schemaCreationStatementsForEntities
public NSArray foreignKeyConstraintStatementsForRelationship(EORelationship aRelationship)
Returns an array of EOSQLExpression objects that define the SQL necessary to create foreign key constraints for aRelationship. EOSQLExpression's implementation generates statements such as the following:
ALTER TABLE EMPLOYEE ADD CONSTRAINT TO_DEPARTMENT FOREIGN KEY (DEPT_ID)
REFERENCES DEPARTMENT(DEPT_ID)
It returns an empty array if either of the following are true:
- aRelationship spans models (if aRelationship's destinationEntity is in a different model than aRelationship's source entity)
- aRelationship is a to-many relationship, or if the inverse relationship of aRelationship is not a to-many. In other words, foreign key constraint statements are only created for to-one relationships whose inverse is a to-many.
If a subclass's database server's foreign key constraint semantics are different, the subclass should override this method or override the method prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:.
See Also: schemaCreationStatementsForEntities
public boolean isCaseSensitive()
Description forthcoming.
public boolean isColumnTypeEquivalentToColumnType( EOSchemaSynchronization.ColumnTypes columnTypeA, EOSchemaSynchronization.ColumnTypes columnTypeB, NSDictionary options)
Returns true
if values in a column of columnTypeA can be copied into a column of columnTypeB without the use of a casting phrase, false
otherwise. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray logicalErrorsInChangeDictionaryForModelOptions( NSDictionary, EOModel, NSDictionary)
Description forthcoming.
public NSDictionary objectStoreChangesFromAttributeToAttribute( EOAttribute anAttribute, EOAttribute anotherAttribute)
Description forthcoming.
public String phraseCastingColumnNamed( String columnName, EOSchemaSynchronization.ColumnTypes fromType, EOSchemaSynchronization.ColumnTypes castType NSDictionary options)
Returns an SQL string to cast the values in the column specified by columnName to a new type. This method is used when the adaptor doesn't support in-place column type coercion, and the table has to be recreated. To move data from the old table to the new table, sometimes a conversion statement is needed (for example, to convert strings in a VARCHAR column to numbers). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray primaryKeyConstraintStatementsForEntityGroup(NSArray entityGroup)
Returns an array of EOSQLExpression objects that define the SQL necessary to create the primary key constraints for entityGroup, an array of EOEntity objects that have the same externalName. Returns an empty array if any of the primary key attributes in entityGroup don't have a columnName.
EOSQLExpression's implementation creates a statement of the following form:
ALTER TABLE TABLE_NAME ADD PRIMARY KEY (PRIMARY_KEY_COLUMN_NAMES)
Where TABLE_NAME is the externalName for the first entity in entityGroup and PRIMARY_KEY_COLUMN_NAMES is a comma-separated list of the columnNames of the first entity's primaryKeyAttributes.
If the subclass's database server's primary key constraint semantics are different, the subclass should override this method.
public NSArray primaryKeyConstraintStatementsForEntityGroups(NSArray entityGroups)
Returns an array of EOSQLExpression objects that define the SQL necessary to create the primary key constraints for the Entities specified in entityGroups. An entity group is an array of Entity objects that have the same externalName, and entityGroups is an array of entity groups. EOSQLExpression's implementation invokes primaryKeySupportStatementsForEntityGroup for each entity group in entityGroups and returns an array of all the resulting EOSQLExpressions.
public NSArray primaryKeySupportStatementsForEntityGroup(NSArray entityGroup)
Returns an array of EOSQLExpression objects that define the SQL necessary to create the primary key generation support for entityGroup, an array of EOEntity objects that have the same externalName. EOSQLExpression's implementation creates a statement of the following form:
create sequence SEQUENCE_NAME
Where SEQUENCE_NAME is the primaryKeyRootName for the first entity in entityGroup concatenated with "_SEQ" (EMP_ID_SEQ, for example).
If a subclass uses a different primary key generation mechanism or if the subclass's database server's drop semantics are different, the subclass should override this method.
See Also: dropPrimaryKeySupportStatementsForEntityGroup, primaryKeyForNewRowWithEntity (EOAdaptorChannel)
public NSArray primaryKeySupportStatementsForEntityGroups(NSArray entityGroups)
Returns an array of EOSQLExpression objects that define the SQL necessary to create the primary key generation support for the Entities specified in entityGroups. An entity group is an array of Entity objects that have the same externalName, and entityGroups is an array of entity groups. EOSQLExpression's implementation invokes primaryKeySupportStatementsForEntityGroup for each entity group in entityGroups and returns an array of all the resulting EOSQLExpressions.
public String schemaCreationScriptForEntities( NSArray entities, NSDictionary options)
Returns a script of SQL statements suitable to create the schema for the EOEntity objects in entities. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306). EOSQLExpression's implementation invokes schemaCreationStatementsForEntities with entities and options and then uses appendExpressionToScript to generate the script from the EOSQLExpressions generated by schemaCreationStatementsForEntities.
public NSArray schemaCreationStatementsForEntities( NSArray entities, NSDictionary options)
Returns an array of EOSQLExpressions suitable to create the schema for the Entity objects in entities. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
EOSQLExpression's implementation uses the following methods:
to generate EOSQLExpressions for the support identified in options.
See Also: schemaCreationScriptForEntities
public EOSynchronizationFactory.Delegate schemaSynchronizationDelegate()
Description forthcoming.
public void setSchemaSynchronizationDelegate( EOSynchronizationFactory.Delegate aDelegate)
Description forthcoming.
public NSArray statementsToConvertColumnType( String columnName, String tableName, EOSchemaSynchronization.ColumnTypes type, EOSchemaSynchronization.ColumnTypes newType, NSDictionary options)
Returns an array of EOSQLExpressions to convert in place the type of the specified column. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToCopyTableNamed( String tableName, NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to copy the specified table into a new table, whose definition is provided by entityGroup-an array of EOEntity objects rooted to the table named tableName. This method is used when the adaptor doesn't support the in-place table modifications required to synchronize the database to a model.
The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToDeleteColumnNamed( String columnName, String tableName, NSDictionary options)
Returns an array of EOSQLExpressions to delete in place the specified column from the specified table. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToDropForeignKeyConstraintsOnEntityGroups( NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to drop foreign key constraints for the table corresponding to entityGroup-an array of EOEntity objects rooted to the same table. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToDropPrimaryKeyConstraintsOnEntityGroups( NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to drop primary key constraints for the table corresponding to entityGroup-an array of EOEntity objects rooted to the same table. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToDropPrimaryKeySupportForEntityGroups( NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to drop the primary key support mechanism for the table corresponding to entityGroup-an array of EOEntity objects rooted to the same table. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToImplementForeignKeyConstraintsOnEntityGroups( NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to implement foreign key constraints on the table corresponding to entityGroup-an array of EOEntity objects rooted to the same table. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToImplementPrimaryKeyConstraintsOnEntityGroups( NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to implement primary key constraints on the table corresponding to entityGroup-an array of EOEntity objects rooted to the same table. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToImplementPrimaryKeySupportForEntityGroups( NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to implement support mechanisms for primary key generation for the table corresponding to entityGroup-an array of EOEntity objects rooted to the same table. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToInsertColumnForAttribute( EOAttribute attribute, NSDictionary options)
Returns an array of EOSQLExpressions to insert in place a column for the specified attribute. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToModifyColumnNullRule( String, String, boolean, NSDictionary)
Description forthcoming.
public NSArray statementsToRenameColumnNamed( String columnName, String tableName, String newName, NSDictionary options)
Returns an array of EOSQLExpressions to rename in place the specified column. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToRenameTableNamed( String tableName, String newName, NSDictionary options)
Returns an array of EOSQLExpressions to rename in place the specified table. The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToUpdateObjectStoreForEntityGroups( NSArray entityGroup, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to update the table that corresponds to entityGroup-an array of EOEntity objects rooted to the same table. Inserts and deletes columns, and updates modified columns. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public NSArray statementsToUpdateObjectStoreForModel( EOModel model, NSDictionary changes, NSDictionary options)
Returns an array of EOSQLExpressions to synchronize the database with model. Prepares the statements to insert and delete new and deleted tables before invoking statementsToUpdateObjectStoreForEntityGroups for each modified table. The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" (page 306). The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" (page 306).
public boolean supportsDirectColumnCoercion()
Returns true
if the adaptor can change the type of an existing column in place, false
otherwise.
public boolean supportsDirectColumnDeletion()
Returns true
if the adaptor can delete columns, false
otherwise.
public boolean supportsDirectColumnInsertion()
Returns true
if the adaptor can add columns to a table, false
otherwise.
public boolean supportsDirectColumnNullRuleModification()
Returns true
if the adaptor can modify the null rule of an existing column in place, false
otherwise.
public boolean supportsDirectColumnRenaming()
Returns true
if the adaptor can rename table columns, false
otherwise.
public boolean supportsSchemaSynchronization()
Returns true
if the adaptor can update the database to reflect changes in a model, false
otherwise.
public boolean isCaseSensitive()
Description forthcoming.
public NSArray logicalErrorsInChangeDictionaryForModelOptions( NSDictionary changes, EOModel model, NSDictionary options)
Description forthcoming.
public NSDictionary objectStoreChangesFromAttributeToAttribute(EOAttribute schemaAttribute, EOAttribute modelAttribute)
Description forthcoming.
public Delegate schemaSynchronizationDelegate()
Returns the factory's delegate.
public void setSchemaSynchronizationDelegate(Delegate delegate)
Sets the factory's delegate.
public NSArray tableEntityGroupsForEntities(NSArray entities)
Returns an array of arrays. Filters out entities without external names or attributes having column names. Groups entities in sub-arrays by external name.
© 2001 Apple Computer, Inc. (Last Published April 13, 2001)