本文整理汇总了Java中org.mybatis.generator.api.dom.java.Method.addAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java Method.addAnnotation方法的具体用法?Java Method.addAnnotation怎么用?Java Method.addAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.generator.api.dom.java.Method
的用法示例。
在下文中一共展示了Method.addAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addImplementationElements
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的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
.getUpdateByPrimaryKeySelectiveStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return rows;"); //$NON-NLS-1$
if (context.getPlugins()
.clientUpdateByPrimaryKeySelectiveMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:25,代码来源:UpdateByPrimaryKeySelectiveMethodGenerator.java
示例2: addImplementationElements
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (generateForJava5) {
method.addSuppressTypeWarningsAnnotation();
method.addAnnotation("@Override"); //$NON-NLS-1$
}
StringBuilder sb = new StringBuilder();
sb.append(method.getReturnType().getShortName());
sb.append(" list = "); //$NON-NLS-1$
sb.append(daoTemplate.getQueryForListMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getSelectByExampleStatementId(), "example")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return list;"); //$NON-NLS-1$
if (context.getPlugins()
.clientSelectByExampleWithoutBLOBsMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:27,代码来源:SelectByExampleWithoutBLOBsMethodGenerator.java
示例3: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
StringBuilder sb = new StringBuilder();
sb.append("@InsertProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getInsertSelectiveStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
GeneratedKey gk = introspectedTable.getGeneratedKey();
if (gk != null) {
addGeneratedKeyAnnotation(method, gk);
}
}
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:18,代码来源:AnnotatedInsertSelectiveMethodGenerator.java
示例4: generateToString
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
private void generateToString(IntrospectedTable introspectedTable, TopLevelClass topLevelClass) {
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.setName("toString");
if(introspectedTable.isJava5Targeted()) {
method.addAnnotation("@Override");
}
this.context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
method.addBodyLine("StringBuilder sb = new StringBuilder();");
method.addBodyLine("sb.append(getClass().getSimpleName());");
method.addBodyLine("sb.append(\" [\");");
// method.addBodyLine("sb.append(\"Hash = \").append(hashCode());");
StringBuilder sb = new StringBuilder();
Iterator var5 = topLevelClass.getFields().iterator();
while(var5.hasNext()) {
Field field = (Field)var5.next();
String property = field.getName();
sb.setLength(0);
sb.append("sb.append(\"").append(", ").append(property).append("=\")").append(".append(").append(property).append(");");
method.addBodyLine(sb.toString());
}
method.addBodyLine("sb.append(\"]\");");
// if(this.useToStringFromRoot && topLevelClass.getSuperClass() != null) {
// method.addBodyLine("sb.append(\", from super class \");");
// method.addBodyLine("sb.append(super.toString());");
// }
method.addBodyLine("return sb.toString();");
topLevelClass.addMethod(method);
}
示例5: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append("@UpdateProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getUpdateByExampleSelectiveStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:14,代码来源:AnnotatedUpdateByExampleSelectiveMethodGenerator.java
示例6: addGeneratedKeyAnnotation
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
protected void addGeneratedKeyAnnotation(Interface interfaze, Method method,
GeneratedKey gk) {
StringBuilder sb = new StringBuilder();
IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
if (introspectedColumn != null) {
if (gk.isJdbcStandard()) {
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Options")); //$NON-NLS-1$
sb.append("@Options(useGeneratedKeys=true,keyProperty=\""); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
} else {
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectKey")); //$NON-NLS-1$
FullyQualifiedJavaType fqjt = introspectedColumn.getFullyQualifiedJavaType();
interfaze.addImportedType(fqjt);
sb.append("@SelectKey(statement=\""); //$NON-NLS-1$
sb.append(gk.getRuntimeSqlStatement());
sb.append("\", keyProperty=\""); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\", before="); //$NON-NLS-1$
sb.append(gk.isIdentity() ? "false" : "true"); //$NON-NLS-1$ //$NON-NLS-2$
sb.append(", resultType="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class)"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
}
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:29,代码来源:AbstractJavaMapperMethodGenerator.java
示例7: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
StringBuilder sb = new StringBuilder();
sb.append("@UpdateProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getUpdateByExampleWithBLOBsStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:13,代码来源:AnnotatedUpdateByExampleWithBLOBsMethodGenerator.java
示例8: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append("@UpdateProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getUpdateByPrimaryKeySelectiveStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
开发者ID:DomKing,项目名称:springbootWeb,代码行数:14,代码来源:AnnotatedUpdateByPrimaryKeySelectiveMethodGenerator.java
示例9: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
StringBuilder sb = new StringBuilder();
sb.append("@UpdateProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getUpdateByExampleSelectiveStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:13,代码来源:AnnotatedUpdateByExampleSelectiveMethodGenerator.java
示例10: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectProvider")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append("@SelectProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getCountByExampleStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
示例11: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append("@UpdateProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getUpdateByExampleStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
开发者ID:DomKing,项目名称:server-utility,代码行数:14,代码来源:AnnotatedUpdateByExampleWithoutBLOBsMethodGenerator.java
示例12: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Method method) {
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
StringBuilder sb = new StringBuilder();
sb.append("@UpdateProvider(type="); //$NON-NLS-1$
sb.append(fqjt.getShortName());
sb.append(".class, method=\""); //$NON-NLS-1$
sb.append(introspectedTable.getUpdateByExampleStatementId());
sb.append("\")"); //$NON-NLS-1$
method.addAnnotation(sb.toString());
}
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:13,代码来源:AnnotatedUpdateByExampleWithoutBLOBsMethodGenerator.java
示例13: addMapperAnnotations
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addMapperAnnotations(Method method) {
method.addAnnotation("@Delete({"); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
javaIndent(sb, 1);
sb.append("\"delete from " ); //$NON-NLS-1$
sb.append(escapeStringForJava(
introspectedTable.getFullyQualifiedTableNameAtRuntime()));
sb.append("\","); //$NON-NLS-1$
method.addAnnotation(sb.toString());
boolean and = false;
Iterator<IntrospectedColumn> iter = introspectedTable.getPrimaryKeyColumns().iterator();
while (iter.hasNext()) {
IntrospectedColumn introspectedColumn = iter.next();
sb.setLength(0);
javaIndent(sb, 1);
if (and) {
sb.append(" \"and "); //$NON-NLS-1$
} else {
sb.append("\"where "); //$NON-NLS-1$
and = true;
}
sb.append(escapeStringForJava(
getEscapedColumnName(introspectedColumn)));
sb.append(" = "); //$NON-NLS-1$
sb.append(getParameterClause(introspectedColumn));
sb.append('\"');
if (iter.hasNext()) {
sb.append(',');
}
method.addAnnotation(sb.toString());
}
method.addAnnotation("})"); //$NON-NLS-1$
}
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:41,代码来源:AnnotatedDeleteByPrimaryKeyMethodGenerator.java
示例14: addResultMapAnnotation
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
private void addResultMapAnnotation(Interface interfaze, Method method) {
interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.ResultMap")); //$NON-NLS-1$
String annotation = String.format("@ResultMap(\"%s.%s\")", //$NON-NLS-1$
introspectedTable.getMyBatis3SqlMapNamespace(),
introspectedTable.getRules().generateResultMapWithBLOBs() ?
introspectedTable.getResultMapWithBLOBsId() : introspectedTable.getBaseResultMapId());
method.addAnnotation(annotation);
}
示例15: addImplementationElements
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的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$
}
// 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);
}
}