Package cn.org.rapid_framework.generator.provider.db.table.model

Examples of cn.org.rapid_framework.generator.provider.db.table.model.Column$EnumMetaDada


   
    private LinkedHashSet<Column> convert2Columns(Sql sql,ResultSetMetaData metadata) throws SQLException, Exception {
      if(metadata == null) return new LinkedHashSet();
      LinkedHashSet<Column> columns = new LinkedHashSet();
          for(int i = 1; i <= metadata.getColumnCount(); i++) {
            Column c = convert2Column(sql,metadata, i);
            if(c == null) throw new IllegalStateException("column must be not null");
        columns.add(c);
          }
      return columns;
    }
View Full Code Here


        //FIXME 如果表有别名,将会找不到表,如 inner join user_info t1, tableName将为t1,应该转换为user_info
        Table table = foundTableByTableNameOrTableAlias(sql, m.getTableName());
        if(table == null) {
          return newColumn(null,m);
        }
          Column column = table.getColumnBySqlName(m.getColumnLabelOrName());
          if(column == null || column.getSqlType() != m.getColumnType()) {
              //可以再尝试解析sql得到 column以解决 password as pwd找不到column问题
              column = newColumn(table,m);
              GLogger.trace("not found column:"+m.getColumnLabelOrName()+" on table:"+table.getSqlName()+" "+BeanHelper.describe(column));
              //isInSameTable以此种判断为错误
          }else {
View Full Code Here

      }
    }

    private Column newColumn(Table table,ResultSetMetaDataHolder m) {
      //Table table, int sqlType, String sqlTypeName,String sqlName, int size, int decimalDigits, boolean isPk,boolean isNullable, boolean isIndexed, boolean isUnique,String defaultValue,String remarks
      Column column = new Column(null,m.getColumnType(),m.getColumnTypeName(),m.getColumnLabelOrName(),m.getColumnDisplaySize(),m.getScale(),false,false,false,false,null,null);
      GLogger.trace("not found on table by table emtpty:"+BeanHelper.describe(column));
      return column;
    }
View Full Code Here

   
    private void execute(ParsedSql parsedSql,Sql sql) throws Exception {
      long start = System.currentTimeMillis();
      for(int i = 0; i < parsedSql.getParameterNames().size(); i++) {
        String paramName = parsedSql.getParameterNames().get(i);
        Column column = findColumnByParamName(parsedSql, sql, paramName);
        if(column == null) {
          column = specialParametersMapping.get(paramName);
          if(column == null) {
            //FIXME 不能猜测的column类型
            column = new Column(null,JdbcType.UNDEFINED.TYPE_CODE,"UNDEFINED",paramName,0,0,false,false,false,false,null,null);
          }
        }
        SqlParameter param = new SqlParameter(column);
       
        param.setParamName(paramName);
View Full Code Here

          || sql.matches("(?s).*[#$]"+paramName+"\\[]\\.?\\w*[#$].*") //match #user[]# $user[]$ #user[].age# for ibatis
         || sql.matches("(?s).*[#$]\\{"+paramName+"\\[[$\\{\\}\\w]+]\\}*.*"); //match #{user[index]}# ${user[${index}]}  for mybatis
    }
 
    private Column findColumnByParamName(ParsedSql parsedSql,Sql sql, String paramName) throws Exception {
      Column column = sql.getColumnByName(paramName);
      if(column == null) {
        //FIXME 还未处理 t.username = :username的t前缀问题,应该直接根据 t.确定属于那一张表,不需要再猜测
        String leftColumn = SqlParseHelper.getColumnNameByRightCondition(parsedSql.toString(), paramName);
        if(leftColumn != null) {
          column = findColumnByParseSql(parsedSql, leftColumn );
View Full Code Here

      try {
          Collection<NameWithAlias> tableNames = SqlParseHelper.getTableNamesByQuery(sql.toString());
          for(NameWithAlias tableName : tableNames) {
            Table t = getTableFromCache(tableName.getName());
            if(t != null) {
              Column column = t.getColumnByName(paramName);
              if(column != null) {
                return column;
              }
            }
          }
View Full Code Here

    if(tableNames.size() > 1) {
        return false;
    }
        Table t = SqlFactory.getTableFromCache(tableNames.iterator().next().getName());
        for(Column c : columns) {
            Column fromTableColumn = new ColumnSet(t.getColumns()).getBySqlName(c.getSqlName());
            if(fromTableColumn == null) {
                return false;
            }
        }
       
View Full Code Here

    private String joinColumnsSqlName() {
        // TODO 未解决 a.*,b.*问题
    StringBuffer sb = new StringBuffer();
    for(Iterator<Column> it = columns.iterator();it.hasNext();) {
      Column c = it.next();
      sb.append(c.getSqlName());
      if(it.hasNext()) sb.append(",");
    }
    return sb.toString();
  }
View Full Code Here

    }
    return null;
  }
 
  public Column getColumnByName(String name) {
      Column c = getColumnBySqlName(name);
      if(c == null) {
        c = getColumnBySqlName(StringHelper.toUnderscoreName(name));
      }
      return c;
  }
View Full Code Here

      if(!table.getSqlName().equalsIgnoreCase(getSqlName())) {
        throw new RuntimeException("cannot custom table properties,sqlName not equals. tableConfig.sqlName:"+getSqlName()+" table.sqlName:"+table.getSqlName());
      }
        if(columns != null) {
            for(ColumnConfig c : columns) {
                Column tableColumn = table.getColumnByName(c.getName());
                if(tableColumn != null) {
                    tableColumn.setJavaType(c.getJavatype()); //FIXME 只能自定义javaType
                }
            }
        }
        if(StringHelper.isNotBlank(getDummyPk())) {
            Column c = table.getColumnBySqlName(getDummyPk());
            if(c != null) {
                c.setPk(true);
            }
        }
        table.setClassName(getClassName());
        if(StringHelper.isNotBlank(remarks)) {
            table.setTableAlias(remarks);
View Full Code Here

TOP

Related Classes of cn.org.rapid_framework.generator.provider.db.table.model.Column$EnumMetaDada

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.