/** * INTERNAL: * Either drop from the database directly or write the statement to a file. * Database objects are root level entities such as tables, views, procs, sequences... */ public void createObject(AbstractSession session, Writer schemaWriter) throws EclipseLinkException { if (schemaWriter == null) { this.createOnDatabase(session); } else { this.buildCreationWriter(session, schemaWriter); if (shouldCreateVPDCalls(session)) { buildVPDCreationPolicyWriter(session, schemaWriter); buildVPDCreationFunctionWriter(session, schemaWriter); } } }
/** * INTERNAL: * Execute the DDL to drop the object. Either directly from the database * of write out the statement to a file. */ public void dropObject(AbstractSession session, Writer schemaWriter, boolean createSQLFiles) throws EclipseLinkException { if (schemaWriter == null) { this.dropFromDatabase(session); } else { buildDeletionWriter(session, schemaWriter); if (shouldCreateVPDCalls(session)) { buildVPDDeletionWriter(session, schemaWriter); } } }
public String toString() { return Helper.getShortClassName(getClass()) + "(" + getFullName() + ")"; } }
/** * INTERNAL: * Either drop from the database directly or write the statement to a file. * Database objects are root level entities such as tables, views, procs, sequences... */ public void createObject(AbstractSession session, Writer schemaWriter) throws EclipseLinkException { if (schemaWriter == null) { this.createOnDatabase(session); } else { this.buildCreationWriter(session, schemaWriter); } }
/** * INTERNAL: * Execute the DDL to drop the object. Either directly from the database * of write out the statement to a file. */ public void dropObject(AbstractSession session, Writer schemaWriter, boolean createSQLFiles) throws EclipseLinkException { if (schemaWriter == null) { this.dropFromDatabase(session); } else { buildDeletionWriter(session, schemaWriter); } }
/** * INTERNAL: * Most major databases support a creator name scope. * This means whenever the database object is referenced, it must be qualified. */ public String getFullName() { if (getQualifier().equals("")) { return getName(); } else { return getQualifier() + "." + getName(); } }
databaseObjectDefinition.createDatabaseSchemaOnDatabase(getSession(), createdDatabaseSchemasOnDatabase); databaseObjectDefinition.createOnDatabase(getSession()); } else { databaseObjectDefinition.createDatabaseSchema(getSession(), createSchemaWriter, createdDatabaseSchemas); appendToDDLWriter(createSchemaWriter, "\n"); databaseObjectDefinition.createObject(getSession(), createSchemaWriter); if (createSQLFiles){ this.appendToDDLWriter(createSchemaWriter, getSession().getPlatform().getStoredProcedureTerminationToken()); databaseObjectDefinition.postCreateObject(getSession(), createSchemaWriter, createSQLFiles); } finally { if (usesBatchWriting) {
databaseObjectDefinition.preDropObject(getSession(), getDropSchemaWriter(), this.createSQLFiles); if (shouldWriteToDatabase()) { databaseObjectDefinition.dropFromDatabase(getSession()); } else { Writer dropSchemaWriter = getDropSchemaWriter(); databaseObjectDefinition.dropObject(getSession(), dropSchemaWriter, createSQLFiles); if (this.createSQLFiles){ this.appendToDDLWriter(dropSchemaWriter, getSession().getPlatform().getStoredProcedureTerminationToken());
/** * INTERNAL: * Execute the DDL to drop the object. */ public void dropFromDatabase(AbstractSession session) throws EclipseLinkException { session.priviledgedExecuteNonSelectingCall(new SQLCall(buildDeletionWriter(session, new StringWriter()).toString())); if (shouldCreateVPDCalls(session)) { session.priviledgedExecuteNonSelectingCall(new SQLCall(buildVPDDeletionWriter(session, new StringWriter()).toString())); } }
/** * Use the definition object to create the schema entity on the database. * This is used for creating tables, views, procedures ... etc ... */ public void createObject(DatabaseObjectDefinition databaseObjectDefinition) throws EclipseLinkException { boolean usesBatchWriting = false; if (getSession().getPlatform().usesBatchWriting()) { usesBatchWriting = true; getSession().getPlatform().setUsesBatchWriting(false); } try { if (shouldWriteToDatabase()) { databaseObjectDefinition.createOnDatabase(getSession()); } else { databaseObjectDefinition.createObject(getSession(), createSchemaWriter); if (createSQLFiles){ this.appendToDDLWriter(createSchemaWriter, getSession().getPlatform().getStoredProcedureTerminationToken()); } this.appendToDDLWriter(createSchemaWriter, "\n"); databaseObjectDefinition.postCreateObject(getSession(), createSchemaWriter, createSQLFiles); } } finally { if (usesBatchWriting) { getSession().getPlatform().setUsesBatchWriting(true); } } }
/** * Use the definition object to drop the schema entity from the database. * This is used for dropping tables, views, procedures ... etc ... */ public void dropObject(DatabaseObjectDefinition databaseObjectDefinition) throws EclipseLinkException { boolean usesBatchWriting = false; if (getSession().getPlatform().usesBatchWriting()) { usesBatchWriting = true; getSession().getPlatform().setUsesBatchWriting(false); } try { if (shouldWriteToDatabase()) { // drop actual object databaseObjectDefinition.dropFromDatabase(getSession()); } else { Writer dropSchemaWriter = getDropSchemaWriter(); // drop actual object databaseObjectDefinition.dropObject(getSession(), dropSchemaWriter, createSQLFiles); if (createSQLFiles){ this.appendToDDLWriter(dropSchemaWriter, getSession().getPlatform().getStoredProcedureTerminationToken()); } this.appendToDDLWriter(dropSchemaWriter, "\n"); } } finally { if (usesBatchWriting) { getSession().getPlatform().setUsesBatchWriting(true); } } }
/** * INTERNAL: * Execute the DDL to create this table. */ public void createOnDatabase(AbstractSession session) throws EclipseLinkException { super.createOnDatabase(session); createIndexOnPrimaryKeyOnDatabase(session); createIndicesOnUniqueKeysOnDatabase(session); }
/** * PUBLIC: * Performs a deep copy of this table definition. */ public Object clone() { TableDefinition clone = (TableDefinition)super.clone(); if (fields != null) { clone.setFields(new Vector<FieldDefinition>(fields.size())); for (Enumeration enumtr = getFields().elements(); enumtr.hasMoreElements();) { FieldDefinition fieldDef = (FieldDefinition)enumtr.nextElement(); clone.addField((FieldDefinition)fieldDef.clone()); } } if (foreignKeyMap != null) { clone.setForeignKeyMap((HashMap) foreignKeyMap.clone()); } if (uniqueKeys != null) { clone.setUniqueKeys((Vector)uniqueKeys.clone()); } return clone; }
/** * Use the definition object to drop and recreate the schema entity on the database. * This is used for dropping tables, views, procedures ... etc ... * This handles and ignore any database error while dropping in case the object did not previously exist. */ public void replaceObject(DatabaseObjectDefinition databaseDefinition) throws EclipseLinkException { // PERF: Allow a special "fast" flag to be set on the session causes a delete from the table instead of a replace. boolean fast = FAST_TABLE_CREATOR; if (fast && (databaseDefinition instanceof TableDefinition)) { session.executeNonSelectingSQL("DELETE FROM " + databaseDefinition.getName()); } else if (fast && (databaseDefinition instanceof StoredProcedureDefinition)) { // do nothing } else { // CR 3870467, do not log stack boolean shouldLogExceptionStackTrace = getSession().getSessionLog().shouldLogExceptionStackTrace(); if (shouldLogExceptionStackTrace) { getSession().getSessionLog().setShouldLogExceptionStackTrace(false); } try { dropObject(databaseDefinition); } catch (DatabaseException exception) { // Ignore error } finally { if (shouldLogExceptionStackTrace) { getSession().getSessionLog().setShouldLogExceptionStackTrace(true); } } createObject(databaseDefinition); } }
/** * INTERNAL: * Execute the DDL to create this object. */ public void createOnDatabase(AbstractSession session) throws EclipseLinkException { session.executeNonSelectingCall(new SQLCall(buildCreationWriter(session, new StringWriter()).toString())); }
/** * INTERNAL: * Execute the DDL to drop the object. */ public void dropFromDatabase(AbstractSession session) throws EclipseLinkException { session.executeNonSelectingCall(new SQLCall(buildDeletionWriter(session, new StringWriter()).toString())); }
/** * INTERNAL: * Execute the DDL to drop the table. */ public void dropFromDatabase(AbstractSession session) throws EclipseLinkException { // first drop indices on table's primary and unique keys (if required) dropIndicesOnUniqueKeysOnDatabase(session); dropIndexOnPrimaryKeyOnDatabase(session); super.dropFromDatabase(session); }
/** * INTERNAL: * Execute the DDL to drop the table. Either directly from the database * of write out the statement to a file. */ public void dropObject(AbstractSession session, Writer schemaWriter, boolean createSQLFiles) throws EclipseLinkException { // first drop indices on table's primary and unique keys (if required) setCreateSQLFiles(createSQLFiles); dropIndicesOnUniqueKeys(session, schemaWriter); dropIndexOnPrimaryKey(session, schemaWriter); super.dropObject(session, schemaWriter, createSQLFiles); }
databaseObjectDefinition.createDatabaseSchemaOnDatabase(getSession(), createdDatabaseSchemasOnDatabase); databaseObjectDefinition.createOnDatabase(getSession()); } else { databaseObjectDefinition.createDatabaseSchema(getSession(), createSchemaWriter, createdDatabaseSchemas); appendToDDLWriter(createSchemaWriter, "\n"); databaseObjectDefinition.createObject(getSession(), createSchemaWriter); if (createSQLFiles){ this.appendToDDLWriter(createSchemaWriter, getSession().getPlatform().getStoredProcedureTerminationToken()); databaseObjectDefinition.postCreateObject(getSession(), createSchemaWriter, createSQLFiles); } finally { if (usesBatchWriting) {
databaseObjectDefinition.preDropObject(getSession(), getDropSchemaWriter(), this.createSQLFiles); if (shouldWriteToDatabase()) { databaseObjectDefinition.dropFromDatabase(getSession()); } else { Writer dropSchemaWriter = getDropSchemaWriter(); databaseObjectDefinition.dropObject(getSession(), dropSchemaWriter, createSQLFiles); if (this.createSQLFiles){ this.appendToDDLWriter(dropSchemaWriter, getSession().getPlatform().getStoredProcedureTerminationToken());