Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptimisticLockerPlugin does not support tables that have multiple primary keys #134

Open
mrk-911 opened this issue Jun 10, 2021 · 0 comments

Comments

@mrk-911
Copy link

mrk-911 commented Jun 10, 2021

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant