本文整理汇总了Java中org.mybatis.generator.api.dom.java.TopLevelClass.addImportedTypes方法的典型用法代码示例。如果您正苦于以下问题:Java TopLevelClass.addImportedTypes方法的具体用法?Java TopLevelClass.addImportedTypes怎么用?Java TopLevelClass.addImportedTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.generator.api.dom.java.TopLevelClass
的用法示例。
在下文中一共展示了TopLevelClass.addImportedTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
StringBuilder sb = new StringBuilder();
sb.append("int rows = "); //$NON-NLS-1$
sb.append(daoTemplate.getDeleteMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getDeleteByExampleStatementId(), "example")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return rows;"); //$NON-NLS-1$
if (context.getPlugins().clientDeleteByExampleMethodGenerated(
method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例2: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
// generate the implementation method
StringBuilder sb = new StringBuilder();
sb.append("Long count = (Long) "); //$NON-NLS-1$
sb.append(daoTemplate.getQueryForObjectMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getCountByExampleStatementId(), "example")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (generateForJava5) {
method.addBodyLine("return count;"); //$NON-NLS-1$
} else {
method.addBodyLine("return count.longValue();"); //$NON-NLS-1$
}
if (context.getPlugins().clientCountByExampleMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:27,代码来源:CountByExampleMethodGenerator.java
示例3: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (generateForJava5) {
method.addSuppressTypeWarningsAnnotation();
}
StringBuilder sb = new StringBuilder();
sb.append(method.getReturnType().getShortName());
sb.append(" list = "); //$NON-NLS-1$
sb.append(daoTemplate.getQueryForListMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getSelectByExampleWithBLOBsStatementId(), "example")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return list;"); //$NON-NLS-1$
if (context.getPlugins()
.clientSelectByExampleWithBLOBsMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例4: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
StringBuilder sb = new StringBuilder();
sb.append("int rows = "); //$NON-NLS-1$
sb.append(daoTemplate.getUpdateMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getUpdateByPrimaryKeyWithBLOBsStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return rows;"); //$NON-NLS-1$
if (context.getPlugins()
.clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例5: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
method
.addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append("int rows = "); //$NON-NLS-1$
sb.append(daoTemplate.getUpdateMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getUpdateByExampleSelectiveStatementId(), "parms")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return rows;"); //$NON-NLS-1$
if (context.getPlugins()
.clientUpdateByExampleSelectiveMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例6: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
method
.addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append("int rows = "); //$NON-NLS-1$
sb.append(daoTemplate.getUpdateMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getUpdateByExampleStatementId(), "parms")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return rows;"); //$NON-NLS-1$
if (context.getPlugins()
.clientUpdateByExampleWithoutBLOBsMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:25,代码来源:UpdateByExampleWithoutBLOBsMethodGenerator.java
示例7: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (generateForJava5) {
method.addAnnotation("@Override"); //$NON-NLS-1$
}
StringBuilder sb = new StringBuilder();
sb.append("int rows = "); //$NON-NLS-1$
sb.append(daoTemplate.getUpdateMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getUpdateByPrimaryKeyWithBLOBsStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return rows;"); //$NON-NLS-1$
if (context.getPlugins()
.clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:25,代码来源:UpdateByPrimaryKeyWithBLOBsMethodGenerator.java
示例8: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
StringBuilder sb = new StringBuilder();
if (!introspectedTable.getRules().generatePrimaryKeyClass()) {
// no primary key class, but primary key is enabled. Primary
// key columns must be in the base class.
FullyQualifiedJavaType keyType = new FullyQualifiedJavaType(
introspectedTable.getBaseRecordType());
topLevelClass.addImportedType(keyType);
sb.setLength(0);
sb.append(keyType.getShortName());
sb.append(" _key = new "); //$NON-NLS-1$
sb.append(keyType.getShortName());
sb.append("();"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
for (IntrospectedColumn introspectedColumn : introspectedTable
.getPrimaryKeyColumns()) {
sb.setLength(0);
sb.append("_key."); //$NON-NLS-1$
sb.append(getSetterMethodName(introspectedColumn
.getJavaProperty()));
sb.append('(');
sb.append(introspectedColumn.getJavaProperty());
sb.append(");"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
}
}
sb.setLength(0);
sb.append("int rows = "); //$NON-NLS-1$
sb.append(daoTemplate.getDeleteMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getDeleteByPrimaryKeyStatementId(), "_key")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return rows;"); //$NON-NLS-1$
if (context.getPlugins().clientDeleteByPrimaryKeyMethodGenerated(
method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例9: addClassElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addClassElements(TopLevelClass topLevelClass) {
Set<String> staticImports = new TreeSet<String>();
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
if (useLegacyBuilder) {
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.BEGIN"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.UPDATE"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SET"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SQL"); //$NON-NLS-1$
} else {
importedTypes.add(NEW_BUILDER_IMPORT);
}
importedTypes.add(new FullyQualifiedJavaType("java.util.Map")); //$NON-NLS-1$
Method method = new Method(getMethodName());
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.setVisibility(JavaVisibility.PUBLIC);
method.addParameter(new Parameter(new FullyQualifiedJavaType("java.util.Map<java.lang.String, java.lang.Object>"), //$NON-NLS-1$
"parameter")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
if (useLegacyBuilder) {
method.addBodyLine("BEGIN();"); //$NON-NLS-1$
} else {
method.addBodyLine("SQL sql = new SQL();"); //$NON-NLS-1$
}
method.addBodyLine(String.format("%sUPDATE(\"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime())));
method.addBodyLine(""); //$NON-NLS-1$
for (IntrospectedColumn introspectedColumn : ListUtilities.removeGeneratedAlwaysColumns(getColumns())) {
StringBuilder sb = new StringBuilder();
sb.append(getParameterClause(introspectedColumn));
sb.insert(2, "record."); //$NON-NLS-1$
method.addBodyLine(String.format("%sSET(\"%s = %s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(getAliasedEscapedColumnName(introspectedColumn)),
sb.toString()));
}
method.addBodyLine(""); //$NON-NLS-1$
FullyQualifiedJavaType example =
new FullyQualifiedJavaType(introspectedTable.getExampleType());
importedTypes.add(example);
method.addBodyLine(String.format("%s example = (%s) parameter.get(\"example\");", //$NON-NLS-1$
example.getShortName(), example.getShortName()));
if (useLegacyBuilder) {
method.addBodyLine("applyWhere(example, true);"); //$NON-NLS-1$
method.addBodyLine("return SQL();"); //$NON-NLS-1$
} else {
method.addBodyLine("applyWhere(sql, example, true);"); //$NON-NLS-1$
method.addBodyLine("return sql.toString();"); //$NON-NLS-1$
}
if (callPlugins(method, topLevelClass)) {
topLevelClass.addStaticImports(staticImports);
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:70,代码来源:ProviderUpdateByExampleWithoutBLOBsMethodGenerator.java
示例10: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
// generate the implementation method
StringBuilder sb = new StringBuilder();
if (!introspectedTable.getRules().generatePrimaryKeyClass()) {
// no primary key class, but primary key is enabled. Primary
// key columns must be in the base class.
FullyQualifiedJavaType keyType = new FullyQualifiedJavaType(
introspectedTable.getBaseRecordType());
topLevelClass.addImportedType(keyType);
sb.setLength(0);
sb.append(keyType.getShortName());
sb.append(" _key = new "); //$NON-NLS-1$
sb.append(keyType.getShortName());
sb.append("();"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
for (IntrospectedColumn introspectedColumn : introspectedTable
.getPrimaryKeyColumns()) {
sb.setLength(0);
sb.append("_key."); //$NON-NLS-1$
sb.append(getSetterMethodName(introspectedColumn
.getJavaProperty()));
sb.append('(');
sb.append(introspectedColumn.getJavaProperty());
sb.append(");"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
}
}
FullyQualifiedJavaType returnType = method.getReturnType();
sb.setLength(0);
sb.append(returnType.getShortName());
sb.append(" record = ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") "); //$NON-NLS-1$
sb.append(daoTemplate.getQueryForObjectMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getSelectByPrimaryKeyStatementId(), "_key")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return record;"); //$NON-NLS-1$
if (context.getPlugins().clientSelectByPrimaryKeyMethodGenerated(
method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例11: addImplementationElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append("Object newKey = "); //$NON-NLS-1$
}
sb.append(daoTemplate.getInsertMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getInsertStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
// no need to cast if the return type is Object
method.addBodyLine("return newKey;"); //$NON-NLS-1$
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType
.getPrimitiveTypeWrapper();
sb.append("return (("); //$NON-NLS-1$
sb.append(ptw.getShortName());
sb.append(") newKey"); //$NON-NLS-1$
sb.append(")."); //$NON-NLS-1$
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
sb.append("return ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") newKey;"); //$NON-NLS-1$
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例12: addClassElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addClassElements(TopLevelClass topLevelClass) {
Set<String> staticImports = new TreeSet<String>();
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
if (useLegacyBuilder) {
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.BEGIN"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SQL"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.VALUES"); //$NON-NLS-1$
} else {
importedTypes.add(NEW_BUILDER_IMPORT);
}
FullyQualifiedJavaType fqjt = introspectedTable.getRules()
.calculateAllFieldsClass();
importedTypes.add(fqjt);
Method method = new Method(
introspectedTable.getInsertSelectiveStatementId());
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addParameter(new Parameter(fqjt, "record")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
if (useLegacyBuilder) {
method.addBodyLine("BEGIN();"); //$NON-NLS-1$
} else {
method.addBodyLine("SQL sql = new SQL();"); //$NON-NLS-1$
}
method.addBodyLine(String.format("%sINSERT_INTO(\"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(introspectedTable.getFullyQualifiedTableNameAtRuntime())));
for (IntrospectedColumn introspectedColumn : ListUtilities.removeIdentityAndGeneratedAlwaysColumns(introspectedTable.getAllColumns())) {
method.addBodyLine(""); //$NON-NLS-1$
if (!introspectedColumn.getFullyQualifiedJavaType().isPrimitive()
&& !introspectedColumn.isSequenceColumn()) {
method.addBodyLine(String.format("if (record.%s() != null) {", //$NON-NLS-1$
getGetterMethodName(introspectedColumn.getJavaProperty(),
introspectedColumn.getFullyQualifiedJavaType())));
}
method.addBodyLine(String.format("%sVALUES(\"%s\", \"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(getEscapedColumnName(introspectedColumn)),
getParameterClause(introspectedColumn)));
if (!introspectedColumn.getFullyQualifiedJavaType().isPrimitive()
&& !introspectedColumn.isSequenceColumn()) {
method.addBodyLine("}"); //$NON-NLS-1$
}
}
method.addBodyLine(""); //$NON-NLS-1$
if (useLegacyBuilder) {
method.addBodyLine("return SQL();"); //$NON-NLS-1$
} else {
method.addBodyLine("return sql.toString();"); //$NON-NLS-1$
}
if (context.getPlugins().providerInsertSelectiveMethodGenerated(method, topLevelClass,
introspectedTable)) {
topLevelClass.addStaticImports(staticImports);
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例13: addClassElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addClassElements(TopLevelClass topLevelClass) {
Set<String> staticImports = new TreeSet<String>();
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
if (useLegacyBuilder) {
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.BEGIN"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SQL"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.VALUES"); //$NON-NLS-1$
} else {
importedTypes.add(NEW_BUILDER_IMPORT);
}
FullyQualifiedJavaType fqjt = introspectedTable.getRules()
.calculateAllFieldsClass();
importedTypes.add(fqjt);
Method method = new Method(
introspectedTable.getInsertSelectiveStatementId());
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addParameter(new Parameter(fqjt, "record")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
if (useLegacyBuilder) {
method.addBodyLine("BEGIN();"); //$NON-NLS-1$
} else {
method.addBodyLine("SQL sql = new SQL();"); //$NON-NLS-1$
}
method.addBodyLine(String.format("%sINSERT_INTO(\"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(introspectedTable.getFullyQualifiedTableNameAtRuntime())));
for (IntrospectedColumn introspectedColumn : ListUtilities.removeIdentityAndGeneratedAlwaysColumns(introspectedTable.getAllColumns())) {
method.addBodyLine(""); //$NON-NLS-1$
if (!introspectedColumn.getFullyQualifiedJavaType().isPrimitive()
&& !introspectedColumn.isSequenceColumn()) {
method.addBodyLine(String.format("if (record.%s() != null) {", //$NON-NLS-1$
getGetterMethodName(introspectedColumn.getJavaProperty(),
introspectedColumn.getFullyQualifiedJavaType())));
}
method.addBodyLine(String.format("%sVALUES(\"%s\", \"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(getEscapedColumnName(introspectedColumn)),
getParameterClause(introspectedColumn)));
if (!introspectedColumn.getFullyQualifiedJavaType().isPrimitive()
&& !introspectedColumn.isSequenceColumn()) {
method.addBodyLine("}"); //$NON-NLS-1$
}
}
method.addBodyLine(""); //$NON-NLS-1$
if (useLegacyBuilder) {
method.addBodyLine("return SQL();"); //$NON-NLS-1$
} else {
method.addBodyLine("return sql.toString();"); //$NON-NLS-1$
}
if (context.getPlugins().providerInsertSelectiveMethodGenerated(method, topLevelClass,
introspectedTable)) {
topLevelClass.addStaticImports(staticImports);
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例14: addClassElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addClassElements(TopLevelClass topLevelClass) {
Set<String> staticImports = new TreeSet<String>();
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
if (useLegacyBuilder) {
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.BEGIN"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.DELETE_FROM"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SQL"); //$NON-NLS-1$
} else {
importedTypes.add(NEW_BUILDER_IMPORT);
}
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getExampleType());
importedTypes.add(fqjt);
Method method = new Method(
introspectedTable.getDeleteByExampleStatementId());
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addParameter(new Parameter(fqjt, "example")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
if (useLegacyBuilder) {
method.addBodyLine("BEGIN();"); //$NON-NLS-1$
method.addBodyLine(String.format("DELETE_FROM(\"%s\");", //$NON-NLS-1$
escapeStringForJava(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime())));
method.addBodyLine("applyWhere(example, false);"); //$NON-NLS-1$
method.addBodyLine("return SQL();"); //$NON-NLS-1$
} else {
method.addBodyLine("SQL sql = new SQL();"); //$NON-NLS-1$
method.addBodyLine(String.format("sql.DELETE_FROM(\"%s\");", //$NON-NLS-1$
escapeStringForJava(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime())));
method.addBodyLine("applyWhere(sql, example, false);"); //$NON-NLS-1$
method.addBodyLine("return sql.toString();"); //$NON-NLS-1$
}
if (context.getPlugins().providerDeleteByExampleMethodGenerated(method, topLevelClass,
introspectedTable)) {
topLevelClass.addStaticImports(staticImports);
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例15: addClassElements
import org.mybatis.generator.api.dom.java.TopLevelClass; //导入方法依赖的package包/类
@Override
public void addClassElements(TopLevelClass topLevelClass) {
Set<String> staticImports = new TreeSet<String>();
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
if (useLegacyBuilder) {
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.BEGIN"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SELECT"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SELECT_DISTINCT"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.FROM"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.ORDER_BY"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SQL"); //$NON-NLS-1$
} else {
importedTypes.add(NEW_BUILDER_IMPORT);
}
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getExampleType());
importedTypes.add(fqjt);
Method method = new Method(getMethodName());
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addParameter(new Parameter(fqjt, "example")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
if (useLegacyBuilder) {
method.addBodyLine("BEGIN();"); //$NON-NLS-1$
} else {
method.addBodyLine("SQL sql = new SQL();"); //$NON-NLS-1$
}
boolean distinctCheck = true;
for (IntrospectedColumn introspectedColumn : getColumns()) {
if (distinctCheck) {
method.addBodyLine("if (example != null && example.isDistinct()) {"); //$NON-NLS-1$
method.addBodyLine(String.format("%sSELECT_DISTINCT(\"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(getSelectListPhrase(introspectedColumn))));
method.addBodyLine("} else {"); //$NON-NLS-1$
method.addBodyLine(String.format("%sSELECT(\"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(getSelectListPhrase(introspectedColumn))));
method.addBodyLine("}"); //$NON-NLS-1$
} else {
method.addBodyLine(String.format("%sSELECT(\"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(getSelectListPhrase(introspectedColumn))));
}
distinctCheck = false;
}
method.addBodyLine(String.format("%sFROM(\"%s\");", //$NON-NLS-1$
builderPrefix,
escapeStringForJava(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime())));
if (useLegacyBuilder) {
method.addBodyLine("applyWhere(example, false);"); //$NON-NLS-1$
} else {
method.addBodyLine("applyWhere(sql, example, false);"); //$NON-NLS-1$
}
method.addBodyLine(""); //$NON-NLS-1$
method.addBodyLine("if (example != null && example.getOrderByClause() != null) {"); //$NON-NLS-1$
method.addBodyLine(String.format("%sORDER_BY(example.getOrderByClause());", builderPrefix)); //$NON-NLS-1$
method.addBodyLine("}"); //$NON-NLS-1$
method.addBodyLine(""); //$NON-NLS-1$
if (useLegacyBuilder) {
method.addBodyLine("return SQL();"); //$NON-NLS-1$
} else {
method.addBodyLine("return sql.toString();"); //$NON-NLS-1$
}
if (callPlugins(method, topLevelClass)) {
topLevelClass.addStaticImports(staticImports);
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:82,代码来源:ProviderSelectByExampleWithoutBLOBsMethodGenerator.java