Commit 30a3539f authored by hewei's avatar hewei

对于Model生成WithBLOBs类时,SelectOneByExample插件实现行为和官方插件保持一致

parent 1f5e57dc
...@@ -16,8 +16,11 @@ ...@@ -16,8 +16,11 @@
package com.itfsw.mybatis.generator.plugins.utils; package com.itfsw.mybatis.generator.plugins.utils;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.*; import org.mybatis.generator.api.dom.java.*;
import static org.mybatis.generator.internal.util.messages.Messages.getString;
/** /**
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
* Java ele 生成工具 * Java ele 生成工具
...@@ -133,4 +136,39 @@ public class JavaElementGeneratorTools { ...@@ -133,4 +136,39 @@ public class JavaElementGeneratorTools {
); );
return generateMethodBody(method, "return this." + field.getName() + ";"); return generateMethodBody(method, "return this." + field.getName() + ";");
} }
/**
* 获取Model没有BLOBs类时的类型
*
* @param introspectedTable
* @return
*/
public static FullyQualifiedJavaType getModelTypeWithoutBLOBs(IntrospectedTable introspectedTable){
FullyQualifiedJavaType type;
if (introspectedTable.getRules().generateBaseRecordClass()) {
type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
} else if (introspectedTable.getRules().generatePrimaryKeyClass()) {
type = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
} else {
throw new RuntimeException(getString("RuntimeError.12"));
}
return type;
}
/**
* 获取Model有BLOBs类时的类型
*
* @param introspectedTable
* @return
*/
public static FullyQualifiedJavaType getModelTypeWithBLOBs(IntrospectedTable introspectedTable){
FullyQualifiedJavaType type;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
type = new FullyQualifiedJavaType(introspectedTable.getRecordWithBLOBsType());
} else {
// the blob fields must be rolled up into the base class
type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
}
return type;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment