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;
}
Aggregations