Skip to content

Commit c63d6da

Browse files
authored
Merge pull request #1118 from octoape/master
Add clientUpdateByPrimaryKeyMethodGenerated method
2 parents afe6f8d + b216a8e commit c63d6da

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

core/mybatis-generator-core/src/main/java/org/mybatis/generator/api/CompositePlugin.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,4 +1274,16 @@ public boolean shouldGenerate(IntrospectedTable introspectedTable) {
12741274

12751275
return true;
12761276
}
1277+
1278+
@Override
1279+
public boolean clientUpdateByPrimaryKeyMethodGenerated(Method method, Interface interfaze,
1280+
IntrospectedTable introspectedTable) {
1281+
for (Plugin plugin : plugins) {
1282+
if (!plugin.clientUpdateByPrimaryKeyMethodGenerated(method, interfaze, introspectedTable)) {
1283+
return false;
1284+
}
1285+
}
1286+
1287+
return true;
1288+
}
12771289
}

core/mybatis-generator-core/src/main/java/org/mybatis/generator/api/Plugin.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,4 +2044,30 @@ default boolean clientUpdateByPrimaryKeyMethodGenerated(KotlinFunction kotlinFun
20442044
default boolean shouldGenerate(IntrospectedTable introspectedTable) {
20452045
return true;
20462046
}
2047+
2048+
/**
2049+
* The motivation for adding this method can be found in
2050+
* https://github.com/mybatis/generator/issues/1116
2051+
*
2052+
* This method is called when the updateByPrimaryKey method
2053+
* has been generated in the dynamic SQL runtime client interface.
2054+
*
2055+
* @param method
2056+
* the generated updateByPrimaryKey method
2057+
* @param interfaze
2058+
* the partially implemented client interface. You can add
2059+
* additional imported classes to the interface if
2060+
* necessary.
2061+
* @param introspectedTable
2062+
* The class containing information about the table as
2063+
* introspected from the database
2064+
* @return true if the method should be generated, false if the generated
2065+
* method should be ignored. In the case of multiple plugins, the
2066+
* first plugin returning false will disable the calling of further
2067+
* plugins.
2068+
*/
2069+
default boolean clientUpdateByPrimaryKeyMethodGenerated(Method method,
2070+
Interface interfaze, IntrospectedTable introspectedTable) {
2071+
return clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(method, interfaze, introspectedTable);
2072+
}
20472073
}

core/mybatis-generator-core/src/main/java/org/mybatis/generator/runtime/dynamic/sql/elements/UpdateByPrimaryKeyMethodGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public MethodAndImports generateMethodAndImports() {
6464

6565
@Override
6666
public boolean callPlugins(Method method, Interface interfaze) {
67-
return context.getPlugins().clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(method,
67+
return context.getPlugins().clientUpdateByPrimaryKeyMethodGenerated(method,
6868
interfaze, introspectedTable);
6969
}
7070

0 commit comments

Comments
 (0)