Ejemplo n.º 1
0
  public void addSetterComment(
      Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
      return;
    }

    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**"); // $NON-NLS-1$
    method.addJavaDocLine(" * This method was generated by MyBatis Generator."); // $NON-NLS-1$

    sb.append(" * This method sets the value of the database column "); // $NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    method.addJavaDocLine(" *"); // $NON-NLS-1$

    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param "); // $NON-NLS-1$
    sb.append(parm.getName());
    sb.append(" the value for "); // $NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());

    addJavadocTag(method, false);

    method.addJavaDocLine(" */"); // $NON-NLS-1$
  }
Ejemplo n.º 2
0
 @Override
 public void initialized(IntrospectedTable introspectedTable) {
   List<IntrospectedColumn> columns = introspectedTable.getAllColumns();
   for (IntrospectedColumn introspectedColumn : columns) {
     String javaProperty =
         this.getJavaName(
             introspectedColumn.getActualColumnName(), introspectedColumn.getJavaProperty());
     introspectedColumn.setJavaProperty(javaProperty);
   }
   super.initialized(introspectedTable);
 }
Ejemplo n.º 3
0
 /**
  * 给字段添加数据库备注
  *
  * @param field
  * @param introspectedTable
  * @param introspectedColumn
  */
 public void addFieldComment(
     Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
   if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
     field.addJavaDocLine("/**");
     StringBuilder sb = new StringBuilder();
     sb.append(" * ");
     sb.append(introspectedColumn.getRemarks());
     field.addJavaDocLine(sb.toString());
     field.addJavaDocLine(" */");
   }
   // 添加注解
   if (field.isTransient()) {
     // @Column
     field.addAnnotation("@Transient");
   }
   for (IntrospectedColumn column : introspectedTable.getPrimaryKeyColumns()) {
     if (introspectedColumn == column) {
       field.addAnnotation("@Id");
       break;
     }
   }
   String column = introspectedColumn.getActualColumnName();
   if (StringUtility.stringContainsSpace(column)
       || introspectedTable.getTableConfiguration().isAllColumnDelimitingEnabled()) {
     column =
         introspectedColumn.getContext().getBeginningDelimiter()
             + column
             + introspectedColumn.getContext().getEndingDelimiter();
   }
   if (!column.equals(introspectedColumn.getJavaProperty())) {
     // @Column
     field.addAnnotation("@Column(name = \"" + column + "\")");
   }
   if (introspectedColumn.isIdentity()) {
     if (introspectedTable
         .getTableConfiguration()
         .getGeneratedKey()
         .getRuntimeSqlStatement()
         .equals("JDBC")) {
       field.addAnnotation("@GeneratedValue(generator = \"JDBC\")");
     } else {
       field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY)");
     }
   } else if (introspectedColumn.isSequenceColumn()) {
     field.addAnnotation(
         "@SequenceGenerator(name=\"\",sequenceName=\""
             + introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement()
             + "\")");
   }
 }
Ejemplo n.º 4
0
 /**
  * getter方法注释
  *
  * @param method
  * @param introspectedTable
  * @param introspectedColumn
  */
 public void addGetterComment(
     Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
   StringBuilder sb = new StringBuilder();
   method.addJavaDocLine("/**");
   if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
     sb.append(" * 获取");
     sb.append(introspectedColumn.getRemarks());
     method.addJavaDocLine(sb.toString());
     method.addJavaDocLine(" *");
   }
   sb.setLength(0);
   sb.append(" * @return ");
   sb.append(introspectedColumn.getActualColumnName());
   if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
     sb.append(" - ");
     sb.append(introspectedColumn.getRemarks());
   }
   method.addJavaDocLine(sb.toString());
   method.addJavaDocLine(" */");
 }