自定义数据库方言
public class MySQL5DialectNoFK extends MySQL5InnoDBDialect {
@Override
public String getTableTypeString() {
return "ENGINE=InnoDB DEFAULT CHARSET=utf8";
}
public MySQL5DialectNoFK() {
super();
registerFunction("order_china", new SQLFunctionTemplate(
new StringType(), "convert(?1 using ?2)"));
}
@Override
public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable,
String[] primaryKey, boolean referencesPrimaryKey) {
String sql = "";
for(String key : foreignKey) {
sql += "alter table" + referencedTable + " drop foreign key " + key + ";";
}
return sql;
}
}
复制代码
转载于:https://juejin.im/post/5c2435da6fb9a049ee80823c