PATH |
EOSchemaGeneration
Implemented by:EOSynchronizationFactory
Package: com.webobjects.eoaccess
Interface Description
This interface has been introduced to define API for generating database schemas from model files. None of the API is new. Rather, it was moved to EOSchemaGeneration from EOSQLExpression. The API is essentially the same except that in 4.5, the methods were static methods. In 5.0 the methods on EOSchemaGeneration are instance methods.
An implementation of the EOSchemaGeneration API is provided by the class, EOSynchronizationFactory, which is new in 5.0. For more information, see the sections for EOSQLExpression and EOSynchronizationFactory.
Constants
EOSchemeGeneration defines the following String constants.
Method Types
Creating a schema generation script schemaCreationScriptForEntities schemaCreationStatementsForEntities appendExpression createTableStatementsForEntityGroup createTableStatementsForEntityGroups dropTableStatementsForEntityGroup dropTableStatementsForEntityGroups primaryKeyConstraintStatementsForEntityGroup primaryKeyConstraintStatementsForEntityGroups primaryKeySupportStatementsForEntityGroup primaryKeySupportStatementsForEntityGroups dropPrimaryKeySupportStatementsForEntityGroup dropPrimaryKeySupportStatementsForEntityGroups foreignKeyConstraintStatementsForRelationship createDatabaseStatementsForConnectionDictionary dropDatabaseStatementsForConnectionDictionary
Instance Methods
appendExpression
public abstract void appendExpressionToScript( EOSQLExpression anSQLExpression, StringBuffer script)
See Also: createTableStatementsForEntityGroup
createDatabaseStatementsForConnectionDictionary
public abstract NSArray createDatabaseStatementsForConnectionDictionary( NSDictionary connectionDictionary, NSDictionary adminDictionary)
See Also: dropDatabaseStatementsForConnectionDictionary
createTableStatementsForEntityGroup
public abstract NSArray createTableStatementsForEntityGroup(NSArray entityGroup)
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
createTableStatementsForEntityGroups
public abstract NSArray createTableStatementsForEntityGroups(NSArray entityGroups)
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 abstract NSArray dropDatabaseStatementsForConnectionDictionary( NSDictionary connectionDictionary, NSDictionary adminDictionary)
See Also: createDatabaseStatementsForConnectionDictionary
dropPrimaryKeySupportStatementsForEntityGroup
public abstract NSArray dropPrimaryKeySupportStatementsForEntityGroup(NSArray entityGroup)
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 abstract NSArray dropPrimaryKeySupportStatementsForEntityGroups(NSArray entityGroups)
See Also: schemaCreationStatementsForEntities
dropTableStatementsForEntityGroup
public abstract NSArray dropTableStatementsForEntityGroup(NSArray entityGroup)
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 abstract NSArray dropTableStatementsForEntityGroups(NSArray entityGroups)
See Also: schemaCreationStatementsForEntities
foreignKeyConstraintStatementsForRelationship
public abstract NSArray foreignKeyConstraintStatementsForRelationship(EORelationship aRelationship)
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
primaryKeyConstraintStatementsForEntityGroup
public abstract NSArray primaryKeyConstraintStatementsForEntityGroup(NSArray entityGroup)
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 abstract NSArray primaryKeyConstraintStatementsForEntityGroups(NSArray entityGroups)
primaryKeySupportStatementsForEntityGroup
public abstract NSArray primaryKeySupportStatementsForEntityGroup(NSArray entityGroup)
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 abstract NSArray primaryKeySupportStatementsForEntityGroups(NSArray entityGroups)
schemaCreationScriptForEntities
public abstract String schemaCreationScriptForEntities( NSArray entities, NSDictionary options)
schemaCreationStatementsForEntities
public abstract NSArray schemaCreationStatementsForEntities( NSArray entities, NSDictionary options)
EOSQLExpression's implementation uses the following methods:
- createTableStatementsForEntityGroups
- dropTableStatementsForEntityGroups
- primaryKeySupportStatementsForEntityGroups
- dropPrimaryKeySupportStatementsForEntityGroups
- primaryKeyConstraintStatementsForEntityGroups
- foreignKeyConstraintStatementsForRelationship
to generate EOSQLExpressions for the support identified in options.
See Also: schemaCreationScriptForEntities
© 2001 Apple Computer, Inc. (Last Published April 13, 2001)