ConstraintDeferrabilityType deferrabilityType) {\r
List<String> columnNames = mapColumnNames(modelFields);\r
List<String> referenceColumnNames = mapColumnNames(refModelFields);\r
- addForeignKey(name, columnNames, refTableName, referenceColumnNames,\r
+ addConstraintForeignKey(name, columnNames, refTableName, referenceColumnNames,\r
deleteType, updateType, deferrabilityType);\r
}\r
\r
- /**\r
- * Defines a foreign key constraint.\r
- * \r
- * @param name\r
- * @param columnNames\r
- */\r
- private void addForeignKey(String name, List<String> columnNames, String referenceTableName, \r
- List<String> referenceColumnNames, ConstraintDeleteType deleteType, \r
- ConstraintUpdateType updateType, ConstraintDeferrabilityType deferrabilityType) {\r
- ConstraintForeignKeyDefinition constraint = new ConstraintForeignKeyDefinition();\r
- if (StringUtils.isNullOrEmpty(name)) {\r
- constraint.constraintName = tableName + "_" + constraintsUnique.size();\r
- } else {\r
- constraint.constraintName = name;\r
- }\r
- constraint.foreignColumns = Utils.newArrayList(columnNames);\r
- constraint.referenceTable = referenceTableName;\r
- constraint.referenceColumns = Utils.newArrayList(referenceColumnNames);\r
- constraint.deleteType = deleteType;\r
- constraint.updateType = updateType;\r
- constraint.deferrabilityType = deferrabilityType;\r
- constraintsForeignKey.add(constraint);\r
- }\r
- \r
void defineColumnName(Object column, String columnName) {\r
FieldDefinition def = fieldMap.get(column);\r
if (def != null) {\r
private void addConstraintForeignKey(IQContraintForeignKey constraint) {\r
List<String> foreignColumns = Arrays.asList(constraint.foreignColumns());\r
List<String> referenceColumns = Arrays.asList(constraint.referenceColumns());\r
- addContraintForeignKey(constraint.name(), foreignColumns, constraint.referenceName(), referenceColumns, constraint.deleteType(), constraint.updateType(), constraint.deferrabilityType());\r
+ addConstraintForeignKey(constraint.name(), foreignColumns, constraint.referenceName(), referenceColumns, constraint.deleteType(), constraint.updateType(), constraint.deferrabilityType());\r
}\r
\r
private void addConstraintUnique(IQContraintUnique constraint) {\r
List<String> uniqueColumns = Arrays.asList(constraint.uniqueColumns());\r
- addContraintUnique(constraint.name(), uniqueColumns);\r
+ addConstraintUnique(constraint.name(), uniqueColumns);\r
}\r
\r
/**\r
* @param deferrabilityType\r
* deferrability mode\r
*/\r
- private void addContraintForeignKey(String name,\r
+ private void addConstraintForeignKey(String name,\r
List<String> foreignColumns, String referenceName,\r
List<String> referenceColumns, ConstraintDeleteType deleteType,\r
ConstraintUpdateType updateType, ConstraintDeferrabilityType deferrabilityType) {\r
constraintsForeignKey.add(constraint);\r
}\r
\r
- /**\r
- * Defines a unique constraint with the specified parameters.\r
- * \r
- * @param name\r
- * name of the constraint\r
- * @param uniqueColumns\r
- * list of columns declared as unique\r
- */\r
- private void addContraintUnique(String name, List<String> uniqueColumns) {\r
- ConstraintUniqueDefinition constraint = new ConstraintUniqueDefinition();\r
- if (StringUtils.isNullOrEmpty(name)) {\r
- constraint.constraintName = tableName + "_" + constraintsUnique.size();\r
- } else {\r
- constraint.constraintName = name;\r
- }\r
- constraint.uniqueColumns = Utils.newArrayList(uniqueColumns);\r
- constraintsUnique.add(constraint);\r
- }\r
-\r
private void addIndex(IQIndex index) {\r
List<String> columns = Arrays.asList(index.value());\r
addIndex(index.name(), index.type(), columns);\r