Examples of FullyQualifiedJavaType


Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

      }
    }
  }

  private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getExampleType());
    importedTypes.add(type);
    importedTypes.add(FullyQualifiedJavaType.getNewListInstance());

    Method method = new Method();
    method.setVisibility(getExampleMethodVisibility());

    FullyQualifiedJavaType returnType = FullyQualifiedJavaType.getNewListInstance();
    ;
    if (generateForJava5) {
      FullyQualifiedJavaType fqjt;
      if (introspectedTable.getRules().generateBaseRecordClass()) {
        fqjt = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
      } else if (introspectedTable.getRules().generatePrimaryKeyClass()) {
        fqjt = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
      } else {
        throw new RuntimeException(getString("RuntimeError.12")); //$NON-NLS-1$
      }

      importedTypes.add(fqjt);
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

  @Override
  public void addImplementationElements(TopLevelClass topLevelClass) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);

    FullyQualifiedJavaType returnType = method.getReturnType();
    StringBuilder sb = new StringBuilder();

    if (returnType != null) {
      sb.append("Object newKey = "); //$NON-NLS-1$
    }

    sb.append(daoTemplate.getInsertMethod(introspectedTable.getIbatis2SqlMapNamespace(),
        introspectedTable.getInsertSelectiveStatementId(), "record")); //$NON-NLS-1$
    method.addBodyLine(sb.toString());

    if (returnType != null) {
      if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
        // no need to cast if the return type is Object
        method.addBodyLine("return newKey;"); //$NON-NLS-1$
      } else {
        sb.setLength(0);

        if (returnType.isPrimitive()) {
          PrimitiveTypeWrapper ptw = returnType.getPrimitiveTypeWrapper();
          sb.append("return (("); //$NON-NLS-1$
          sb.append(ptw.getShortName());
          sb.append(") newKey"); //$NON-NLS-1$
          sb.append(")."); //$NON-NLS-1$
          sb.append(ptw.getToPrimitiveMethod());
          sb.append(';');
        } else {
          sb.append("return ("); //$NON-NLS-1$
          sb.append(returnType.getShortName());
          sb.append(") newKey;"); //$NON-NLS-1$
        }

        method.addBodyLine(sb.toString());
      }
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

  }

  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);
    method.setName(getDAOMethodNameCalculator().getInsertSelectiveMethodName(introspectedTable));

    FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass();

    importedTypes.add(parameterType);
    method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$

    for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

    StringBuilder sb = new StringBuilder();

    if (!introspectedTable.getRules().generatePrimaryKeyClass()) {
      // no primary key class, but primary key is enabled. Primary
      // key columns must be in the base class.
      FullyQualifiedJavaType keyType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
      topLevelClass.addImportedType(keyType);

      sb.setLength(0);
      sb.append(keyType.getShortName());
      sb.append(" _key = new "); //$NON-NLS-1$
      sb.append(keyType.getShortName());
      sb.append("();"); //$NON-NLS-1$
      method.addBodyLine(sb.toString());

      for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
        sb.setLength(0);
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(getDAOMethodNameCalculator().getDeleteByPrimaryKeyMethodName(introspectedTable));

    if (introspectedTable.getRules().generatePrimaryKeyClass()) {
      FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
      importedTypes.add(type);
      method.addParameter(new Parameter(type, "_key")); //$NON-NLS-1$
    } else {
      for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
        FullyQualifiedJavaType type = introspectedColumn.getFullyQualifiedJavaType();
        importedTypes.add(type);
        method.addParameter(new Parameter(type, introspectedColumn.getJavaProperty()));
      }
    }
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

      }
    }
  }

  private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
    FullyQualifiedJavaType parameterType;
    if (introspectedTable.getRules().generateBaseRecordClass()) {
      parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    } else {
      parameterType = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
    }

    importedTypes.add(parameterType);

    Method method = new Method();
    method.setVisibility(getExampleMethodVisibility());
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(getDAOMethodNameCalculator().getUpdateByExampleWithoutBLOBsMethodName(introspectedTable));
    method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
    method.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), "example")); //$NON-NLS-1$

    for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
      method.addException(fqjt);
      importedTypes.add(fqjt);
    }
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

  @Override
  public void addImplementationElements(TopLevelClass topLevelClass) {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = getMethodShell(importedTypes);

    FullyQualifiedJavaType returnType = method.getReturnType();

    StringBuilder sb = new StringBuilder();

    if (returnType != null) {
      sb.append("Object newKey = "); //$NON-NLS-1$
    }

    sb.append(daoTemplate.getInsertMethod(introspectedTable.getIbatis2SqlMapNamespace(),
        introspectedTable.getInsertStatementId(), "record")); //$NON-NLS-1$
    method.addBodyLine(sb.toString());

    if (returnType != null) {
      if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
        // no need to cast if the return type is Object
        method.addBodyLine("return newKey;"); //$NON-NLS-1$
      } else {
        sb.setLength(0);

        if (returnType.isPrimitive()) {
          PrimitiveTypeWrapper ptw = returnType.getPrimitiveTypeWrapper();
          sb.append("return (("); //$NON-NLS-1$
          sb.append(ptw.getShortName());
          sb.append(") newKey"); //$NON-NLS-1$
          sb.append(")."); //$NON-NLS-1$
          sb.append(ptw.getToPrimitiveMethod());
          sb.append(';');
        } else {
          sb.append("return ("); //$NON-NLS-1$
          sb.append(returnType.getShortName());
          sb.append(") newKey;"); //$NON-NLS-1$
        }

        method.addBodyLine(sb.toString());
      }
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

  }

  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);
    method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$

    for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

    super();
  }

  @Override
  public void addImplementationElements(TopLevelClass topLevelClass) {
    topLevelClass.addImportedType(new FullyQualifiedJavaType(introspectedTable.getExampleType()));

    InnerClass innerClass = new InnerClass(new FullyQualifiedJavaType("UpdateByExampleParms")); //$NON-NLS-1$
    innerClass.setVisibility(JavaVisibility.PROTECTED);
    innerClass.setStatic(true);
    innerClass.setSuperClass(introspectedTable.getExampleType());
    context.getCommentGenerator().addClassComment(innerClass, introspectedTable);

    Method method = new Method();
    method.setConstructor(true);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName(innerClass.getType().getShortName());
    method.addParameter(new Parameter(FullyQualifiedJavaType.getObjectInstance(), "record")); //$NON-NLS-1$
    method.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), "example")); //$NON-NLS-1$
    method.addBodyLine("super(example);"); //$NON-NLS-1$
    method.addBodyLine("this.record = record;"); //$NON-NLS-1$
    innerClass.addMethod(method);

    Field field = new Field();
View Full Code Here

Examples of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType

      }
    }
  }

  private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
    FullyQualifiedJavaType parameterType;

    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
      parameterType = new FullyQualifiedJavaType(introspectedTable.getRecordWithBLOBsType());
    } else if (introspectedTable.getRules().generateBaseRecordClass()) {
      parameterType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    } else {
      parameterType = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
    }

    importedTypes.add(parameterType);

    Method method = new Method();
    method.setVisibility(getExampleMethodVisibility());
    method.setReturnType(FullyQualifiedJavaType.getIntInstance());
    method.setName(getDAOMethodNameCalculator().getUpdateByExampleSelectiveMethodName(introspectedTable));
    method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
    method.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), "example")); //$NON-NLS-1$

    for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
      method.addException(fqjt);
      importedTypes.add(fqjt);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.