Java Code Examples for org.mybatis.generator.api.dom.java.Interface#addImportedType()

The following examples show how to use org.mybatis.generator.api.dom.java.Interface#addImportedType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotatedInsertSelectiveMethodGenerator.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.InsertProvider")); //$NON-NLS-1$
    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(interfaze, method, gk);
    }
}
 
Example 2
Source File: AnnotatedSelectByExampleWithBLOBsMethodGenerator.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
@Override
public void addExtraImports(Interface interfaze) {
    interfaze.addImportedType(
            new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectProvider"));
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.type.JdbcType"));

    if (introspectedTable.isConstructorBased()) {
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Arg"));
        interfaze.addImportedType(
                new FullyQualifiedJavaType("org.apache.ibatis.annotations.ConstructorArgs"));
    } else {
        interfaze.addImportedType(
                new FullyQualifiedJavaType("org.apache.ibatis.annotations.Result"));
        interfaze.addImportedType(
                new FullyQualifiedJavaType("org.apache.ibatis.annotations.Results"));
    }
}
 
Example 3
Source File: MapperAnnotationPlugin.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public boolean clientGenerated(Interface interfaze, IntrospectedTable introspectedTable) {

    if (introspectedTable.getTargetRuntime() == TargetRuntime.MYBATIS3) {
        // don't need to do this for MYBATIS3_DSQL as that runtime already adds this annotation 
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Mapper"));
        interfaze.addAnnotation("@Mapper");
    }
    return true;
}
 
Example 4
Source File: SimpleJavaClientGenerator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    progressCallback.startTask(getString("Progress.17", introspectedTable.getFullyQualifiedTable().toString()));
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getMyBatis3JavaMapperType());
    Interface interfaze = new Interface(type);
    interfaze.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(interfaze);

    String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
    if (!stringHasValue(rootInterface)) {
        rootInterface = context.getJavaClientGeneratorConfiguration().getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
    }

    if (stringHasValue(rootInterface)) {
        FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(rootInterface);
        interfaze.addSuperInterface(fqjt);
        interfaze.addImportedType(fqjt);
    }

    addDeleteByPrimaryKeyMethod(interfaze);
    addInsertMethod(interfaze);
    addSelectByPrimaryKeyMethod(interfaze);
    addSelectAllMethod(interfaze);
    addUpdateByPrimaryKeyMethod(interfaze);

    List<CompilationUnit> answer = new ArrayList<>();
    if (context.getPlugins().clientGenerated(interfaze, introspectedTable)) {
        answer.add(interfaze);
    }

    List<CompilationUnit> extraCompilationUnits = getExtraCompilationUnits();
    if (extraCompilationUnits != null) {
        answer.addAll(extraCompilationUnits);
    }

    return answer;
}
 
Example 5
Source File: AnnotatedUpdateByExampleSelectiveMethodGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 6
Source File: MapperPlugin.java    From tk-mybatis with MIT License 5 votes vote down vote up
/**
 * 生成的Mapper接口
 *
 * @param interfaze
 * @param topLevelClass
 * @param introspectedTable
 * @return
 */
@Override
public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    //获取实体类
    FullyQualifiedJavaType entityType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    //import接口
    for (String mapper : mappers) {
        interfaze.addImportedType(new FullyQualifiedJavaType(mapper));
        interfaze.addSuperInterface(new FullyQualifiedJavaType(mapper + "<" + entityType.getShortName() + ">"));
    }
    //import实体类
    interfaze.addImportedType(entityType);
    return true;
}
 
Example 7
Source File: AnnotatedDeleteByExampleMethodGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.DeleteProvider")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append("@DeleteProvider(type="); //$NON-NLS-1$
    sb.append(fqjt.getShortName());
    sb.append(".class, method=\""); //$NON-NLS-1$
    sb.append(introspectedTable.getDeleteByExampleStatementId());
    sb.append("\")"); //$NON-NLS-1$
    
    method.addAnnotation(sb.toString());
}
 
Example 8
Source File: AnnotatedUpdateByExampleWithBLOBsMethodGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@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.getUpdateByExampleWithBLOBsStatementId());
    sb.append("\")"); //$NON-NLS-1$
    
    method.addAnnotation(sb.toString());
}
 
Example 9
Source File: CreateSubPackagePlugin.java    From mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
	FullyQualifiedJavaType modelType = new FullyQualifiedJavaType(modelProperties.getOriginalType());
	if (interfaze != null) {
		interfaze.addImportedType(modelType);
	}
	if (topLevelClass != null) {
		topLevelClass.addImportedType(modelType);
	}

	return true;
}
 
Example 10
Source File: AnnotatedSelectByPrimaryKeyMethodGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
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\")", //$NON-NLS-1$
            introspectedTable.getRules().generateResultMapWithBLOBs() ?
                    introspectedTable.getResultMapWithBLOBsId() : introspectedTable.getBaseResultMapId());
    method.addAnnotation(annotation);
}
 
Example 11
Source File: AnnotatedUpdateByExampleWithBLOBsMethodGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@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.getUpdateByExampleWithBLOBsStatementId());
    sb.append("\")"); //$NON-NLS-1$
    
    method.addAnnotation(sb.toString());
}
 
Example 12
Source File: AbstractJavaMapperMethodGenerator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
protected String getResultAnnotation(Interface interfaze, IntrospectedColumn introspectedColumn,
        boolean idColumn, boolean constructorBased) {
    StringBuilder sb = new StringBuilder();
    if (constructorBased) {
        interfaze.addImportedType(introspectedColumn.getFullyQualifiedJavaType());
        sb.append("@Arg(column=\"");
        sb.append(getRenamedColumnNameForResultMap(introspectedColumn));
        sb.append("\", javaType=");
        sb.append(introspectedColumn.getFullyQualifiedJavaType().getShortName());
        sb.append(".class");
    } else {
        sb.append("@Result(column=\"");
        sb.append(getRenamedColumnNameForResultMap(introspectedColumn));
        sb.append("\", property=\"");
        sb.append(introspectedColumn.getJavaProperty());
        sb.append('\"');
    }

    if (stringHasValue(introspectedColumn.getTypeHandler())) {
        FullyQualifiedJavaType fqjt =
                new FullyQualifiedJavaType(introspectedColumn.getTypeHandler());
        interfaze.addImportedType(fqjt);
        sb.append(", typeHandler=");
        sb.append(fqjt.getShortName());
        sb.append(".class");
    }

    sb.append(", jdbcType=JdbcType.");
    sb.append(introspectedColumn.getJdbcTypeName());
    if (idColumn) {
        sb.append(", id=true");
    }
    sb.append(')');

    return sb.toString();
}
 
Example 13
Source File: AnnotatedDeleteByPrimaryKeyMethodGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Delete")); //$NON-NLS-1$
    
    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$
}
 
Example 14
Source File: AnnotatedDeleteByPrimaryKeyMethodGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Delete")); //$NON-NLS-1$
    
    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$
}
 
Example 15
Source File: AnnotatedSelectByPrimaryKeyMethodGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Select")); //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();
    method.addAnnotation("@Select({"); //$NON-NLS-1$
    javaIndent(sb, 1);
    sb.append("\"select\","); //$NON-NLS-1$
    method.addAnnotation(sb.toString());
    
    Iterator<IntrospectedColumn> iter = introspectedTable
        .getAllColumns().iterator();
    sb.setLength(0);
    javaIndent(sb, 1);
    sb.append('"');
    boolean hasColumns = false;
    while (iter.hasNext()) {
        sb.append(escapeStringForJava(getSelectListPhrase(iter.next())));
        hasColumns = true;

        if (iter.hasNext()) {
            sb.append(", "); //$NON-NLS-1$
        }

        if (sb.length() > 80) {
            sb.append("\","); //$NON-NLS-1$
            method.addAnnotation(sb.toString());
            
            sb.setLength(0);
            javaIndent(sb, 1);
            sb.append('"');
            hasColumns = false;
        }
    }

    if (hasColumns) {
        sb.append("\","); //$NON-NLS-1$
        method.addAnnotation(sb.toString());
    }
    
    sb.setLength(0);
    javaIndent(sb, 1);
    sb.append("\"from "); //$NON-NLS-1$
    sb.append(escapeStringForJava(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime()));
    sb.append("\","); //$NON-NLS-1$
    method.addAnnotation(sb.toString());
    
    boolean and = false;
    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(getAliasedEscapedColumnName(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$

    if (useResultMapIfAvailable) {
        if (introspectedTable.getRules().generateBaseResultMap()
                || introspectedTable.getRules().generateResultMapWithBLOBs()) {
            addResultMapAnnotation(interfaze, method);
        } else {
            addAnnotatedResults(interfaze, method);
        }
    } else {
        addAnnotatedResults(interfaze, method);
    }
}
 
Example 16
Source File: SimpleJavaClientGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    progressCallback.startTask(getString("Progress.17", //$NON-NLS-1$
            introspectedTable.getFullyQualifiedTable().toString()));
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getMyBatis3JavaMapperType());
    Interface interfaze = new Interface(type);
    interfaze.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(interfaze);

    String rootInterface = introspectedTable
        .getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
    if (!stringHasValue(rootInterface)) {
        rootInterface = context.getJavaClientGeneratorConfiguration()
            .getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
    }

    if (stringHasValue(rootInterface)) {
        FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(
                rootInterface);
        interfaze.addSuperInterface(fqjt);
        interfaze.addImportedType(fqjt);
    }
    
    addDeleteByPrimaryKeyMethod(interfaze);
    addInsertMethod(interfaze);
    addSelectByPrimaryKeyMethod(interfaze);
    addSelectAllMethod(interfaze);
    addUpdateByPrimaryKeyMethod(interfaze);

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().clientGenerated(interfaze, null,
            introspectedTable)) {
        answer.add(interfaze);
    }
    
    List<CompilationUnit> extraCompilationUnits = getExtraCompilationUnits();
    if (extraCompilationUnits != null) {
        answer.addAll(extraCompilationUnits);
    }

    return answer;
}
 
Example 17
Source File: AnnotatedSelectAllMethodGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Select")); //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();
    method.addAnnotation("@Select({"); //$NON-NLS-1$
    javaIndent(sb, 1);
    sb.append("\"select\","); //$NON-NLS-1$
    method.addAnnotation(sb.toString());
    
    Iterator<IntrospectedColumn> iter = introspectedTable
        .getAllColumns().iterator();
    sb.setLength(0);
    javaIndent(sb, 1);
    sb.append('"');
    boolean hasColumns = false;
    while (iter.hasNext()) {
        sb.append(escapeStringForJava(getSelectListPhrase(iter.next())));
        hasColumns = true;

        if (iter.hasNext()) {
            sb.append(", "); //$NON-NLS-1$
        }

        if (sb.length() > 80) {
            sb.append("\","); //$NON-NLS-1$
            method.addAnnotation(sb.toString());
            
            sb.setLength(0);
            javaIndent(sb, 1);
            sb.append('"');
            hasColumns = false;
        }
    }

    if (hasColumns) {
        sb.append("\","); //$NON-NLS-1$
        method.addAnnotation(sb.toString());
    }
    
    String orderByClause = introspectedTable.getTableConfigurationProperty(PropertyRegistry.TABLE_SELECT_ALL_ORDER_BY_CLAUSE);
    boolean hasOrderBy = StringUtility.stringHasValue(orderByClause);
    
    sb.setLength(0);
    javaIndent(sb, 1);
    sb.append("\"from "); //$NON-NLS-1$
    sb.append(escapeStringForJava(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime()));
    sb.append('\"');
    if (hasOrderBy) {
        sb.append(',');
    }
    method.addAnnotation(sb.toString());
    
    if (hasOrderBy) {
        sb.setLength(0);
        javaIndent(sb, 1);
        sb.append("\"order by "); //$NON-NLS-1$
        sb.append(orderByClause);
        sb.append('\"');
        method.addAnnotation(sb.toString());
    }
    
    method.addAnnotation("})"); //$NON-NLS-1$

    addAnnotatedResults(interfaze, method);
}
 
Example 18
Source File: AnnotatedSelectAllMethodGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Select")); //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();
    method.addAnnotation("@Select({"); //$NON-NLS-1$
    javaIndent(sb, 1);
    sb.append("\"select\","); //$NON-NLS-1$
    method.addAnnotation(sb.toString());
    
    Iterator<IntrospectedColumn> iter = introspectedTable
        .getAllColumns().iterator();
    sb.setLength(0);
    javaIndent(sb, 1);
    sb.append('"');
    boolean hasColumns = false;
    while (iter.hasNext()) {
        sb.append(escapeStringForJava(getSelectListPhrase(iter.next())));
        hasColumns = true;

        if (iter.hasNext()) {
            sb.append(", "); //$NON-NLS-1$
        }

        if (sb.length() > 80) {
            sb.append("\","); //$NON-NLS-1$
            method.addAnnotation(sb.toString());
            
            sb.setLength(0);
            javaIndent(sb, 1);
            sb.append('"');
            hasColumns = false;
        }
    }

    if (hasColumns) {
        sb.append("\","); //$NON-NLS-1$
        method.addAnnotation(sb.toString());
    }
    
    String orderByClause = introspectedTable.getTableConfigurationProperty(PropertyRegistry.TABLE_SELECT_ALL_ORDER_BY_CLAUSE);
    boolean hasOrderBy = StringUtility.stringHasValue(orderByClause);
    
    sb.setLength(0);
    javaIndent(sb, 1);
    sb.append("\"from "); //$NON-NLS-1$
    sb.append(escapeStringForJava(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime()));
    sb.append('\"');
    if (hasOrderBy) {
        sb.append(',');
    }
    method.addAnnotation(sb.toString());
    
    if (hasOrderBy) {
        sb.setLength(0);
        javaIndent(sb, 1);
        sb.append("\"order by "); //$NON-NLS-1$
        sb.append(orderByClause);
        sb.append('\"');
        method.addAnnotation(sb.toString());
    }
    
    method.addAnnotation("})"); //$NON-NLS-1$

    addAnnotatedResults(interfaze, method);
}
 
Example 19
Source File: AnnotatedUpdateByExampleWithBLOBsMethodGenerator.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
@Override
public void addExtraImports(Interface interfaze) {
    interfaze.addImportedType(
            new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider"));
}
 
Example 20
Source File: JavaMapperGenerator.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    progressCallback.startTask(getString("Progress.17", introspectedTable.getFullyQualifiedTable().toString()));
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getMyBatis3JavaMapperType());
    Interface interfaze = new Interface(type);
    interfaze.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(interfaze);

    String rootInterface = introspectedTable
            .getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
    if (!stringHasValue(rootInterface)) {
        rootInterface = context.getJavaClientGeneratorConfiguration()
                .getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
    }

    if (stringHasValue(rootInterface)) {
        FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(
                rootInterface);
        interfaze.addSuperInterface(fqjt);
        interfaze.addImportedType(fqjt);
    }

    addCountByExampleMethod(interfaze);
    addDeleteByExampleMethod(interfaze);
    addDeleteByPrimaryKeyMethod(interfaze);
    addInsertMethod(interfaze);
    addInsertSelectiveMethod(interfaze);
    addInsertBatchMethod(interfaze);
    addSelectByExampleWithBLOBsMethod(interfaze);
    addSelectByExampleWithoutBLOBsMethod(interfaze);
    addSelectByPrimaryKeyMethod(interfaze);
    addUpdateByExampleSelectiveMethod(interfaze);
    addUpdateByExampleWithBLOBsMethod(interfaze);
    addUpdateByExampleWithoutBLOBsMethod(interfaze);
    addUpdateByPrimaryKeySelectiveMethod(interfaze);
    addUpdateByPrimaryKeyWithBLOBsMethod(interfaze);
    addUpdateByPrimaryKeyWithoutBLOBsMethod(interfaze);

    List<CompilationUnit> answer = new ArrayList<>();
    if (context.getPlugins().clientGenerated(interfaze, introspectedTable)) {
        answer.add(interfaze);
    }

    List<CompilationUnit> extraCompilationUnits = getExtraCompilationUnits();
    if (extraCompilationUnits != null) {
        answer.addAll(extraCompilationUnits);
    }

    return answer;
}