Search in sources :

Example 16 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class AnnotatedSelectByExampleWithBLOBsMethodGenerator method addMapperAnnotations.

@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    sb.append("@SelectProvider(type=");
    sb.append(fqjt.getShortName());
    //$NON-NLS-1$
    sb.append(".class, method=\"");
    sb.append(introspectedTable.getSelectByExampleWithBLOBsStatementId());
    //$NON-NLS-1$
    sb.append("\")");
    method.addAnnotation(sb.toString());
    if (introspectedTable.isConstructorBased()) {
        //$NON-NLS-1$
        method.addAnnotation("@ConstructorArgs({");
    } else {
        //$NON-NLS-1$
        method.addAnnotation("@Results({");
    }
    Iterator<IntrospectedColumn> iterPk = introspectedTable.getPrimaryKeyColumns().iterator();
    Iterator<IntrospectedColumn> iterNonPk = introspectedTable.getNonPrimaryKeyColumns().iterator();
    while (iterPk.hasNext()) {
        IntrospectedColumn introspectedColumn = iterPk.next();
        sb.setLength(0);
        javaIndent(sb, 1);
        sb.append(getResultAnnotation(interfaze, introspectedColumn, true, introspectedTable.isConstructorBased()));
        if (iterPk.hasNext() || iterNonPk.hasNext()) {
            sb.append(',');
        }
        method.addAnnotation(sb.toString());
    }
    while (iterNonPk.hasNext()) {
        IntrospectedColumn introspectedColumn = iterNonPk.next();
        sb.setLength(0);
        javaIndent(sb, 1);
        sb.append(getResultAnnotation(interfaze, introspectedColumn, false, introspectedTable.isConstructorBased()));
        if (iterNonPk.hasNext()) {
            sb.append(',');
        }
        method.addAnnotation(sb.toString());
    }
    //$NON-NLS-1$
    method.addAnnotation("})");
}
Also used : IntrospectedColumn(org.mybatis.generator.api.IntrospectedColumn) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)

Example 17 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class AnnotatedSelectByExampleWithBLOBsMethodGenerator method addExtraImports.

@Override
public void addExtraImports(Interface interfaze) {
    //$NON-NLS-1$
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectProvider"));
    //$NON-NLS-1$
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.type.JdbcType"));
    if (introspectedTable.isConstructorBased()) {
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Arg"));
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.ConstructorArgs"));
    } else {
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Result"));
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Results"));
    }
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)

Example 18 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class AnnotatedSelectByExampleWithoutBLOBsMethodGenerator method addExtraImports.

@Override
public void addExtraImports(Interface interfaze) {
    //$NON-NLS-1$
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectProvider"));
    //$NON-NLS-1$
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.type.JdbcType"));
    if (introspectedTable.isConstructorBased()) {
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Arg"));
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.ConstructorArgs"));
    } else {
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Result"));
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Results"));
    }
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)

Example 19 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class AnnotatedSelectByPrimaryKeyMethodGenerator method addAnnotationImports.

private void addAnnotationImports(Interface interfaze) {
    //$NON-NLS-1$
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.type.JdbcType"));
    if (introspectedTable.isConstructorBased()) {
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Arg"));
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.ConstructorArgs"));
    } else {
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Result"));
        //$NON-NLS-1$
        interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Results"));
    }
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)

Example 20 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class AnnotatedUpdateByExampleWithBLOBsMethodGenerator method addMapperAnnotations.

@Override
public void addMapperAnnotations(Method method) {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    sb.append("@UpdateProvider(type=");
    sb.append(fqjt.getShortName());
    //$NON-NLS-1$
    sb.append(".class, method=\"");
    sb.append(introspectedTable.getUpdateByExampleWithBLOBsStatementId());
    //$NON-NLS-1$
    sb.append("\")");
    method.addAnnotation(sb.toString());
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)

Aggregations

FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)163 Method (org.mybatis.generator.api.dom.java.Method)97 Parameter (org.mybatis.generator.api.dom.java.Parameter)54 TreeSet (java.util.TreeSet)53 IntrospectedColumn (org.mybatis.generator.api.IntrospectedColumn)32 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)19 Field (org.mybatis.generator.api.dom.java.Field)19 TopLevelClass (org.mybatis.generator.api.dom.java.TopLevelClass)19 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)14 CommentGenerator (org.mybatis.generator.api.CommentGenerator)11 CompilationUnit (org.mybatis.generator.api.dom.java.CompilationUnit)11 Interface (org.mybatis.generator.api.dom.java.Interface)10 FullyQualifiedTable (org.mybatis.generator.api.FullyQualifiedTable)7 GeneratedKey (org.mybatis.generator.config.GeneratedKey)7 Plugin (org.mybatis.generator.api.Plugin)5 Attribute (org.mybatis.generator.api.dom.xml.Attribute)5 TextElement (org.mybatis.generator.api.dom.xml.TextElement)5 XmlElement (org.mybatis.generator.api.dom.xml.XmlElement)5 JavaBeansUtil.getJavaBeansField (org.mybatis.generator.internal.util.JavaBeansUtil.getJavaBeansField)5