Example #1
0
 /**
  * Add a foreign column to a table not yet created. Note: this method assumes that the foreign
  * table will be created in the same root as this table, like with {@link ChangeTable#cat(List,
  * String)}.
  *
  * @param fk the field name, e.g. "ID_BAT".
  * @param createTable the table the new column must point to.
  * @return this.
  * @see #addForeignColumn(String, SQLName, String, String)
  */
 public T addForeignColumn(String fk, SQLCreateTableBase<?> createTable) {
   final List<String> primaryKey = createTable.getPrimaryKey();
   if (primaryKey.size() != 1)
     throw new IllegalArgumentException(
         "Not exactly one field in the foreign primary key : " + primaryKey);
   return this.addForeignColumn(fk, new SQLName(createTable.getName()), primaryKey.get(0), null);
 }
Example #2
0
 /**
  * Add a foreign column to a table not yet created.
  *
  * @param suffix the suffix of the column, used to tell apart multiple columns pointing to the
  *     same table, e.g. "" or "2".
  * @param createTable the table the new column must point to.
  * @return this.
  * @see #addForeignColumn(String, SQLCreateTableBase)
  */
 public T addForeignColumnWithSuffix(String suffix, SQLCreateTableBase<?> createTable) {
   final String fk =
       SQLKey.PREFIX + createTable.getName() + (suffix.length() == 0 ? "" : "_" + suffix);
   return this.addForeignColumn(fk, createTable);
 }