Search in sources :

Example 61 with FullyQualifiedJavaType

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

the class UpdateByPrimaryKeySelectiveMethodGenerator method addImplementationElements.

@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    sb.append("int rows = ");
    sb.append(daoTemplate.getUpdateMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getUpdateByPrimaryKeySelectiveStatementId(), //$NON-NLS-1$
    "record"));
    method.addBodyLine(sb.toString());
    //$NON-NLS-1$
    method.addBodyLine("return rows;");
    if (context.getPlugins().clientUpdateByPrimaryKeySelectiveMethodGenerated(method, topLevelClass, introspectedTable)) {
        topLevelClass.addImportedTypes(importedTypes);
        topLevelClass.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Method(org.mybatis.generator.api.dom.java.Method)

Example 62 with FullyQualifiedJavaType

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

the class UpdateByPrimaryKeyWithBLOBsMethodGenerator method getMethodShell.

private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
    FullyQualifiedJavaType parameterType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getRecordWithBLOBsType());
    } else {
        parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    }
    importedTypes.add(parameterType);
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(getDAOMethodNameCalculator().getUpdateByPrimaryKeyWithBLOBsMethodName(introspectedTable));
    //$NON-NLS-1$
    method.addParameter(new Parameter(parameterType, "record"));
    for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
        method.addException(fqjt);
        importedTypes.add(fqjt);
    }
    context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable);
    return method;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 63 with FullyQualifiedJavaType

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

the class UpdateByPrimaryKeyWithBLOBsMethodGenerator method addInterfaceElements.

@Override
public void addInterfaceElements(Interface interfaze) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);
    if (context.getPlugins().clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(method, interfaze, introspectedTable)) {
        interfaze.addImportedTypes(importedTypes);
        interfaze.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Method(org.mybatis.generator.api.dom.java.Method)

Example 64 with FullyQualifiedJavaType

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

the class UpdateByPrimaryKeyWithoutBLOBsMethodGenerator method addInterfaceElements.

@Override
public void addInterfaceElements(Interface interfaze) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);
    if (context.getPlugins().clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(method, interfaze, introspectedTable)) {
        interfaze.addImportedTypes(importedTypes);
        interfaze.addMethod(method);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Method(org.mybatis.generator.api.dom.java.Method)

Example 65 with FullyQualifiedJavaType

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

the class AbstractDAOTemplate method getMethodClones.

/**
     * Gets the method clones.
     *
     * @param commentGenerator
     *            the comment generator
     * @param introspectedTable
     *            the introspected table
     * @return the method clones
     */
public final List<Method> getMethodClones(CommentGenerator commentGenerator, IntrospectedTable introspectedTable) {
    configure();
    List<Method> answer = new ArrayList<Method>();
    for (Method oldMethod : methods) {
        Method method = new Method();
        for (String bodyLine : oldMethod.getBodyLines()) {
            method.addBodyLine(bodyLine);
        }
        for (FullyQualifiedJavaType fqjt : oldMethod.getExceptions()) {
            method.addException(fqjt);
        }
        for (Parameter parm : oldMethod.getParameters()) {
            method.addParameter(parm);
        }
        method.setConstructor(oldMethod.isConstructor());
        method.setFinal(oldMethod.isFinal());
        method.setStatic(oldMethod.isStatic());
        method.setName(oldMethod.getName());
        method.setReturnType(oldMethod.getReturnType());
        method.setVisibility(oldMethod.getVisibility());
        commentGenerator.addGeneralMethodComment(method, introspectedTable);
        answer.add(method);
    }
    return answer;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) ArrayList(java.util.ArrayList) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

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