PATH Documentation > WebObjects

Table of Contents

EOSynchronizationFactory


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



EOSynchronizationFactory

public EOSynchronizationFactory(EOAdaptor adaptor)

Description forthcoming.


Instance Methods



appendExpressionToScript

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



createDatabaseStatementsForConnectionDictionary

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



createTableStatementsForEntityGroup

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:

  1. Creates an EOSQLExpression object.
  2. Sets the expression's entity to the first entity in entityGroup.
  3. Adds a create clause for each Attribute in entityGroup's Entities.
  4. 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.
  5. Adds the expression to an array.
  6. 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:

See Also: createTableStatementsForEntityGroup, dropTableStatementsForEntityGroup



createTableStatementsForEntityGroups

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



dropDatabaseStatementsForConnectionDictionary

public NSArray dropDatabaseStatementsForConnectionDictionary( NSDictionary connectionDictionary, NSDictionary adminDictionary)

Generates the SQL statements to drop a database (or user, for Oracle).

See Also: createDatabaseStatementsForConnectionDictionary



dropPrimaryKeySupportStatementsForEntityGroup

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.



dropPrimaryKeySupportStatementsForEntityGroups

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



dropTableStatementsForEntityGroup

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.



dropTableStatementsForEntityGroups

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



foreignKeyConstraintStatementsForRelationship

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:

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



isCaseSensitive

public boolean isCaseSensitive()

Description forthcoming.

isColumnTypeEquivalentToColumnType

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).

logicalErrorsInChangeDictionaryForModelOptions

public NSArray logicalErrorsInChangeDictionaryForModelOptions( NSDictionary, EOModel, NSDictionary)

Description forthcoming.

objectStoreChangesFromAttributeToAttribute

public NSDictionary objectStoreChangesFromAttributeToAttribute( EOAttribute anAttribute, EOAttribute anotherAttribute)

Description forthcoming.

phraseCastingColumnNamed

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).

primaryKeyConstraintStatementsForEntityGroup

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.



primaryKeyConstraintStatementsForEntityGroups

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.

primaryKeySupportStatementsForEntityGroup

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)



primaryKeySupportStatementsForEntityGroups

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.

schemaCreationScriptForEntities

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.

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



schemaSynchronizationDelegate

public EOSynchronizationFactory.Delegate schemaSynchronizationDelegate()

Description forthcoming.

setSchemaSynchronizationDelegate

public void setSchemaSynchronizationDelegate( EOSynchronizationFactory.Delegate aDelegate)

Description forthcoming.

statementsToConvertColumnType

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).

statementsToCopyTableNamed

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).



statementsToDeleteColumnNamed

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).

statementsToDropForeignKeyConstraintsOnEntityGroups

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).

statementsToDropPrimaryKeyConstraintsOnEntityGroups

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).

statementsToDropPrimaryKeySupportForEntityGroups

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).

statementsToImplementForeignKeyConstraintsOnEntityGroups

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).

statementsToImplementPrimaryKeyConstraintsOnEntityGroups

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).

statementsToImplementPrimaryKeySupportForEntityGroups

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).

statementsToInsertColumnForAttribute

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).

statementsToModifyColumnNullRule

public NSArray statementsToModifyColumnNullRule( String, String, boolean, NSDictionary)

Description forthcoming.

statementsToRenameColumnNamed

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).

statementsToRenameTableNamed

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).

statementsToUpdateObjectStoreForEntityGroups

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).

statementsToUpdateObjectStoreForModel

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).

supportsDirectColumnCoercion

public boolean supportsDirectColumnCoercion()

Returns true if the adaptor can change the type of an existing column in place, false otherwise.

supportsDirectColumnDeletion

public boolean supportsDirectColumnDeletion()

Returns true if the adaptor can delete columns, false otherwise.

supportsDirectColumnInsertion

public boolean supportsDirectColumnInsertion()

Returns true if the adaptor can add columns to a table, false otherwise.

supportsDirectColumnNullRuleModification

public boolean supportsDirectColumnNullRuleModification()

Returns true if the adaptor can modify the null rule of an existing column in place, false otherwise.

supportsDirectColumnRenaming

public boolean supportsDirectColumnRenaming()

Returns true if the adaptor can rename table columns, false otherwise.

supportsSchemaSynchronization

public boolean supportsSchemaSynchronization()

Returns true if the adaptor can update the database to reflect changes in a model, false otherwise.

isCaseSensitive

public boolean isCaseSensitive()

Description forthcoming.

logicalErrorsInChangeDictionaryForModelOptions

public NSArray logicalErrorsInChangeDictionaryForModelOptions( NSDictionary changes, EOModel model, NSDictionary options)

Description forthcoming.

objectStoreChangesFromAttributeToAttribute

public NSDictionary objectStoreChangesFromAttributeToAttribute(EOAttribute schemaAttribute, EOAttribute modelAttribute)

Description forthcoming.

schemaSynchronizationDelegate

public Delegate schemaSynchronizationDelegate()

Returns the factory's delegate.

setSchemaSynchronizationDelegate

public void setSchemaSynchronizationDelegate(Delegate delegate)

Sets the factory's delegate.

tableEntityGroupsForEntities

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)


Table of Contents