Assuming you want to support H2, MySQL
Would it make sense to override the MySQL5InnoDBDialect.getAddForeignKeyConstraintString method and prevent creation of index here. So that you can use the @Index, @ForiegnKey annotations seamlessly for all databases to generate similar SQL. Appreciate inputs on this.
public String getAddForeignKeyConstraintString( String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey ) { String cols = StringHelper.join(", ", foreignKey); return new StringBuffer(30) .append(" add index ") .append(constraintName) .append(" (") .append(cols) .append("), add constraint ") .append(constraintName) .append(" foreign key (") .append(cols) .append(") references ") .append(referencedTable) .append(" (") .append( StringHelper.join(", ", primaryKey) ) .append(')') .toString(); }
|