mybatis-generator-plugin
mybatis-generator-plugin copied to clipboard
OptimisticLockerPlugin does not support tables that have multiple primary keys
When generating mapper for tables that have multiple primary keys and have version column, the parameter of deleteWithVersionByPrimaryKey() method contains only the first primary key.
/**
* 替换主键 方法
* @param introspectedTable
* @param method
* @param interfaze
* @param methodName
* @return
*/
private Method replaceDeletePrimaryKeyMethod(IntrospectedTable introspectedTable, Method method, Interface interfaze, String methodName) {
Method withVersionMethod = new Method(method);
// 替换方法名
withVersionMethod.setName(methodName);
FormatTools.replaceGeneralMethodComment(commentGenerator, withVersionMethod, introspectedTable);
Parameter versionParam = new Parameter(this.versionColumn.getFullyQualifiedJavaType(), "version", "@Param(\"version\")");
Parameter keyParam = new Parameter(method.getParameters().get(0).getType(), method.getParameters().get(0).getName(), "@Param(\"key\")");
withVersionMethod.getParameters().clear();
withVersionMethod.addParameter(versionParam);
withVersionMethod.addParameter(keyParam);
return withVersionMethod;
}