Search in sources :

Example 1 with DAOMethodNameCalculator

use of org.mybatis.generator.api.DAOMethodNameCalculator in project generator by mybatis.

the class InsertMethodGenerator method getMethodShell.

private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
    Method method = new Method();
    FullyQualifiedJavaType returnType;
    if (introspectedTable.getGeneratedKey() != null) {
        IntrospectedColumn introspectedColumn = introspectedTable.getColumn(introspectedTable.getGeneratedKey().getColumn());
        if (introspectedColumn == null) {
            // the specified column doesn't exist, so don't do the generated
            // key
            // (the warning has already been reported)
            returnType = null;
        } else {
            returnType = introspectedColumn.getFullyQualifiedJavaType();
            importedTypes.add(returnType);
        }
    } else {
        returnType = null;
    }
    method.setReturnType(returnType);
    method.setVisibility(JavaVisibility.PUBLIC);
    DAOMethodNameCalculator methodNameCalculator = getDAOMethodNameCalculator();
    method.setName(methodNameCalculator.getInsertMethodName(introspectedTable));
    FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass();
    importedTypes.add(parameterType);
    //$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 : IntrospectedColumn(org.mybatis.generator.api.IntrospectedColumn) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) DAOMethodNameCalculator(org.mybatis.generator.api.DAOMethodNameCalculator) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Aggregations

DAOMethodNameCalculator (org.mybatis.generator.api.DAOMethodNameCalculator)1 IntrospectedColumn (org.mybatis.generator.api.IntrospectedColumn)1 FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)1 Method (org.mybatis.generator.api.dom.java.Method)1 Parameter (org.mybatis.generator.api.dom.java.Parameter)1