/** * PUBLIC: * Add a foreign key constraint to the table. * If there is a same name foreign key constraint already, nothing will happen. */ public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey) { if (! hasUserDefinedForeignKeyConstraints) { if (!foreignKeyMap.containsKey(foreignKey.getName())) { foreignKeyMap.put(foreignKey.getName(), foreignKey); } } }
/** * PUBLIC: * Add a foreign key constraint to the table. * If there is a same name foreign key constraint already, nothing will happen. */ public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey) { if (! hasUserDefinedForeignKeyConstraints) { if (!foreignKeyMap.containsKey(foreignKey.getName())) { foreignKeyMap.put(foreignKey.getName(), foreignKey); } } }
/** * PUBLIC: * Add a foreign key constraint to the table. * If there is a same name foreign key constraint already, nothing will happen. */ public void addForeignKeyConstraint(ForeignKeyConstraint foreignKey) { if (!foreignKeyMap.containsKey(foreignKey.getName())) { foreignKeyMap.put(foreignKey.getName(), foreignKey); } }
public void addForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint) { if (foreignKeyConstraints == null) { foreignKeyConstraints = new HashMap<String, ForeignKeyConstraint>(); } foreignKeyConstraints.put(foreignKeyConstraint.getName(), foreignKeyConstraint); }
public void addForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint) { if (foreignKeyConstraints == null) { foreignKeyConstraints = new HashMap<String, ForeignKeyConstraint>(); } foreignKeyConstraints.put(foreignKeyConstraint.getName(), foreignKeyConstraint); }
/** * PUBLIC: * Set the ForeignKeyConstraint list. * If the list contains the same name foreign key constraints, only the first one of that name will be added. */ public void setForeignKeys(Vector<ForeignKeyConstraint> foreignKeys) { foreignKeyMap.clear(); if (foreignKeys != null) { for(ForeignKeyConstraint foreignKey : foreignKeys) { foreignKeyMap.put(foreignKey .getName(), foreignKey); } } }
/** * PUBLIC: * Set the ForeignKeyConstraint list. * If the list contains the same name foreign key constraints, only the first one of that name will be added. */ public void setForeignKeys(List<ForeignKeyConstraint> foreignKeys) { this.foreignKeyMap.clear(); if (foreignKeys != null) { for( ForeignKeyConstraint foreignKey : foreignKeys) { this.foreignKeyMap.put(foreignKey.getName(), foreignKey); } } }
/** * PUBLIC: * Set the ForeignKeyConstraint list. * If the list contains the same name foreign key constraints, only the first one of that name will be added. */ public void setForeignKeys(List<ForeignKeyConstraint> foreignKeys) { this.foreignKeyMap.clear(); if (foreignKeys != null) { for( ForeignKeyConstraint foreignKey : foreignKeys) { this.foreignKeyMap.put(foreignKey.getName(), foreignKey); } } }
/** * INTERNAL: * Return the alter table statement to drop the constraints. * This is done separately to allow constraints to be dropped before the tables. */ public Writer buildConstraintDeletionWriter(AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException { try { writer.write("ALTER TABLE " + getFullName()); writer.write(session.getPlatform().getConstraintDeletionString() + foreignKey.getName()); } catch (IOException ioException) { throw ValidationException.fileError(ioException); } return writer; }
/** * INTERNAL: * Return the alter table statement to drop the constraints. * This is done separately to allow constraints to be dropped before the tables. */ public Writer buildConstraintDeletionWriter(AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException { try { writer.write("ALTER TABLE " + getFullName()); writer.write(session.getPlatform().getConstraintDeletionString() + foreignKey.getName()); } catch (IOException ioException) { throw ValidationException.fileError(ioException); } return writer; }
/** * INTERNAL: * Return the alter table statement to drop the constraints. * This is done separately to allow constraints to be dropped before the tables. */ public Writer buildConstraintDeletionWriter(AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException { try { writer.write("ALTER TABLE " + getFullName()); writer.write(session.getPlatform().getConstraintDeletionString() + foreignKey.getName()); } catch (IOException ioException) { throw ValidationException.fileError(ioException); } return writer; }
protected void addForeignKeyLines(ForeignKeyConstraint foreignKey, NonreflectiveMethodDefinition method) { String foreignKeyName = "foreignKey" + foreignKey.getName(); method.addLine("ForeignKeyConstraint " + foreignKeyName + " = new ForeignKeyConstraint();"); method.addLine(foreignKeyName + ".setName(\"" + foreignKey.getName() + "\");"); method.addLine(foreignKeyName + ".setTargetTable(\"" + foreignKey.getTargetTable() + "\");"); for (Enumeration sourceFieldsEnum = foreignKey.getSourceFields().elements(); sourceFieldsEnum.hasMoreElements();) { method.addLine(foreignKeyName + ".addSourceField(\"" + sourceFieldsEnum.nextElement() + "\");"); } for (Enumeration targetFieldsEnum = foreignKey.getTargetFields().elements(); targetFieldsEnum.hasMoreElements();) { method.addLine(foreignKeyName + ".addTargetField(\"" + targetFieldsEnum.nextElement() + "\");"); } method.addLine("table.addForeignKeyConstraint(" + foreignKeyName + ");"); }
/** * INTERNAL: * Return the alter table statement to add the constraints. * This is done separately from the create because of dependencies. */ public Writer buildConstraintCreationWriter(AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException { try { writer.write("ALTER TABLE " + getFullName()); writer.write(" ADD CONSTRAINT "); if (!session.getPlatform().shouldPrintConstraintNameAfter()) { writer.write(foreignKey.getName() + " "); } foreignKey.appendDBString(writer, session); if (session.getPlatform().shouldPrintConstraintNameAfter()) { writer.write(" CONSTRAINT " + foreignKey.getName()); } } catch (IOException ioException) { throw ValidationException.fileError(ioException); } return writer; }
/** * INTERNAL: * Return the alter table statement to add the constraints. * This is done separately from the create because of dependencies. */ public Writer buildConstraintCreationWriter(AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException { try { writer.write("ALTER TABLE " + getFullName()); writer.write(" ADD CONSTRAINT "); if (!session.getPlatform().shouldPrintConstraintNameAfter()) { writer.write(foreignKey.getName() + " "); } foreignKey.appendDBString(writer, session); if (session.getPlatform().shouldPrintConstraintNameAfter()) { writer.write(" CONSTRAINT " + foreignKey.getName()); } } catch (IOException ioException) { throw ValidationException.fileError(ioException); } return writer; }
/** * INTERNAL: * Return the alter table statement to add the constraints. * This is done separately from the create because of dependencies. */ public Writer buildConstraintCreationWriter(AbstractSession session, ForeignKeyConstraint foreignKey, Writer writer) throws ValidationException { try { writer.write("ALTER TABLE " + getFullName()); writer.write(" ADD CONSTRAINT "); if (!session.getPlatform().shouldPrintConstraintNameAfter()) { writer.write(foreignKey.getName() + " "); } foreignKey.appendDBString(writer, session); if (session.getPlatform().shouldPrintConstraintNameAfter()) { writer.write(" CONSTRAINT " + foreignKey.getName()); } } catch (IOException ioException) { throw ValidationException.fileError(ioException); } return writer; }
protected void addForeignKeyLines(ForeignKeyConstraint foreignKey, NonreflectiveMethodDefinition method) { String foreignKeyName = "foreignKey" + foreignKey.getName(); method.addLine("ForeignKeyConstraint " + foreignKeyName + " = new ForeignKeyConstraint();"); method.addLine(foreignKeyName + ".setName(\"" + foreignKey.getName() + "\");"); method.addLine(foreignKeyName + ".setTargetTable(\"" + foreignKey.getTargetTable() + "\");"); for (String sourceField : foreignKey.getSourceFields()) { method.addLine(foreignKeyName + ".addSourceField(\"" + sourceField + "\");"); } for (String targetField : foreignKey.getTargetFields()) { method.addLine(foreignKeyName + ".addTargetField(\"" + targetField + "\");"); } method.addLine("table.addForeignKeyConstraint(" + foreignKeyName + ");"); }
protected void addForeignKeyLines(ForeignKeyConstraint foreignKey, NonreflectiveMethodDefinition method) { String foreignKeyName = "foreignKey" + foreignKey.getName(); method.addLine("ForeignKeyConstraint " + foreignKeyName + " = new ForeignKeyConstraint();"); method.addLine(foreignKeyName + ".setName(\"" + foreignKey.getName() + "\");"); method.addLine(foreignKeyName + ".setTargetTable(\"" + foreignKey.getTargetTable() + "\");"); for (String sourceField : foreignKey.getSourceFields()) { method.addLine(foreignKeyName + ".addSourceField(\"" + sourceField + "\");"); } for (String targetField : foreignKey.getTargetFields()) { method.addLine(foreignKeyName + ".addTargetField(\"" + targetField + "\");"); } method.addLine("table.addForeignKeyConstraint(" + foreignKeyName + ");"); }
IndexDefinition index = buildIndex(session, foreignKey.getName(), foreignKey.getSourceFields(), false); if (writer == null) { try {
IndexDefinition index = buildIndex(session, foreignKey.getName(), foreignKey.getSourceFields(), false); if (writer == null) { try {
IndexDefinition index = buildIndex(session, foreignKey.getName(), foreignKey.getSourceFields(), false); if (writer == null) { try {