Package org.qdao.annotation

Examples of org.qdao.annotation.Column


    List<TableDescriptor.ColumnDescription> columnDescriptors =
        new ArrayList<TableDescriptor.ColumnDescription>();

    List<String> primaryKeys = new ArrayList<String>();
    List<TableDescriptor.ColumnDescription> pks = new ArrayList<TableDescriptor.ColumnDescription>();
    Column co;
    PrimaryKey pk;
    TableDescriptor.ColumnDescription cd;
/*    TableDescriptor.FkDescription fkd;
    String fkTableName;
    ForeignKey fk;
*/    for (int i = 0; i < fields.length; i++) {
      co = fields[i].getAnnotation(Column.class);
      pk = fields[i].getAnnotation(PrimaryKey.class);
//      fk = fields[i].getAnnotation(ForeignKey.class);
      if (co != null) {
        cd = new TableDescriptor.ColumnDescription();
        cd.decimal = co.decimal();
        cd.description = co.description();
        cd.name = co.name();
        cd.length = co.length();
        cd.nullable = co.nullable();
        cd.type = co.type();
        cd.javaField = fields[i].getName();
        cd.primaryKey = null != pk;
        cd.autoIncrement = co.autoIncrement();
        cd.defaultValue = co.defaultValue();
        columnDescriptors.add(cd);
       
        if (cd.primaryKey) {
          pks.add(cd);
        }
       
        /*if (fk != null) {
          table = fk.getClass().getAnnotation(Table.class);
          fkTableName = null == table ? null : table.name();
          if (null != fkTableName) {
            fkd = new TableDescriptor.FkDescription();
            fkd.foreignKeys = "("  + co.name();
            fkd.references = fkTableName + " (";
          }
        }*/
      }

      if (pk != null) {
        primaryKeys.add(co.name());
      }
    }
    // set the columns
    tableDescriptor.columns = columnDescriptors.toArray(
        new TableDescriptor.ColumnDescription[columnDescriptors.size()]);
View Full Code Here


        new ArrayList<TableDescriptor.ColumnDescription>();

    List<String> primaryKeys = new ArrayList<String>();

    for (int i = 0; i < fields.length; i++) {
      Column column = fields[i].getAnnotation(Column.class);
      if (column != null) {
        TableDescriptor.ColumnDescription columnDescription = new TableDescriptor.ColumnDescription();
        columnDescription.decimal = column.decimal();
        columnDescription.description = column.description();
        columnDescription.name = column.name();
        columnDescription.length = column.length();
        columnDescription.nullable = column.nullable();
        columnDescription.type = column.type();
        columnDescriptors.add(columnDescription);
      }
      PrimaryKey primaryKey = fields[i].getAnnotation(PrimaryKey.class);
      if (primaryKey != null) {
        primaryKeys.add(column.name());
      }
    }

    // set the columns
    tableDescriptor.columns =
View Full Code Here

        new ArrayList<TableDescriptor.ColumnDescription>();

    List<String> primaryKeys = new ArrayList<String>();

    for (int i = 0; i < fields.length; i++) {
      Column column = fields[i].getAnnotation(Column.class);
      if (column != null) {
        TableDescriptor.ColumnDescription columnDescription = new TableDescriptor.ColumnDescription();
        columnDescription.decimal = column.decimal();
        columnDescription.description = column.description();
        columnDescription.name = column.name();
        columnDescription.length = column.length();
        columnDescription.nullable = column.nullable();
        columnDescription.type = column.type();
        columnDescriptors.add(columnDescription);
      }
      PrimaryKey primaryKey = fields[i].getAnnotation(PrimaryKey.class);
      if (primaryKey != null) {
        primaryKeys.add(column.name());
      }
    }

    // set the columns
    tableDescriptor.columns =
View Full Code Here

        new ArrayList<TableDescriptor.ColumnDescription>();

    List<String> primaryKeys = new ArrayList<String>();

    for (int i = 0; i < fields.length; i++) {
      Column column = fields[i].getAnnotation(Column.class);
      if (column != null) {
        TableDescriptor.ColumnDescription columnDescription = new TableDescriptor.ColumnDescription();
        columnDescription.decimal = column.decimal();
        columnDescription.description = column.description();
        columnDescription.name = column.name();
        columnDescription.length = column.length();
        columnDescription.nullable = column.nullable();
        columnDescription.type = column.type();
        columnDescriptors.add(columnDescription);
      }
      PrimaryKey primaryKey = fields[i].getAnnotation(PrimaryKey.class);
      if (primaryKey != null) {
        primaryKeys.add(column.name());
      }
    }

    // set the columns
    tableDescriptor.columns =
View Full Code Here

  private Object getPrimaryKeyValue(final String primaryKey, final T key) {
    Field[] fields = entity.getDeclaredFields();
    if (null != fields && fields.length > 0) {
      for (int i = 0; i < fields.length; i++) {
        if (fields[i].isAnnotationPresent(Column.class) && fields[i].isAnnotationPresent(PrimaryKey.class)) {
          Column column = fields[i].getAnnotation(Column.class);
          if (column.name().equals(primaryKey)) {
            try {
              return fields[i].get(key);
            } catch (IllegalArgumentException e) {
              e.printStackTrace();
            } catch (IllegalAccessException e) {
View Full Code Here

        throw new RuntimeException("DTO内不含有Table注解Annotation");
      }
      sql.append("INSERT INTO ").append(table.name()).append(" (");
      Field[] fields = clz.getDeclaredFields();
      Object value = null;
      Column column;
      for (int i = 0; i < fields.length; i++) {
        column = fields[i].getAnnotation(Column.class);
        if ( !fields[i].isAccessible() ) {
          fields[i].setAccessible( true );
        }
        try {
          value = fields[i].get(dto);
        } catch (IllegalArgumentException e) {
          e.printStackTrace();
        } catch (IllegalAccessException e) {
          e.printStackTrace();
        }
        if (null != value && column != null) {
          sql.append(column.name() + ',');
          symbol.append("?,");
        }
      }
      sql.deleteCharAt(sql.length() - 1);
      symbol.deleteCharAt(symbol.length() - 1);
View Full Code Here

      throw new RuntimeException("DTO内不含有Table注解Annotation");
    }
    sql.append("INSERT INTO ").append(table.name()).append(" (");
    Field[] fields = clz.getDeclaredFields();
    Object value = null;
    Column column;
    for (int i = 0; i < fields.length; i++) {
      column = fields[i].getAnnotation(Column.class);
      try {
        value = fields[i].get(dto);
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }
      if (null != value && column != null) {
        sql.append(column.name() + ',');
        symbol.append("?,");
      }
    }
    sql.deleteCharAt(sql.length() - 1);
    symbol.deleteCharAt(symbol.length() - 1);
View Full Code Here

TOP

Related Classes of org.qdao.annotation.Column

Copyright © 2018 www.massapicom. 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.