Package com.lingbobu.flashdb.common

Examples of com.lingbobu.flashdb.common.ResultSetMeta


      columnInfos[i] = columnInfos[n];
      columnInfos[n] = tmp;
      columnIndexs.put(columnInfos[i].getName(), i);
      columnIndexs.put(columnInfos[n].getName(), n);
    }
    return new ResultSetMeta(columnInfos, keyColumns.size(), tableName, (nAutoIncrement >= 0));
  }
View Full Code Here


    this.joinFieldRelate = joinFieldRelate;
    this.fieldMainIsArray = fieldMainIsArray;
    this.innerJoin = innerJoin;
   
    this.dataSqlIsComplex = false;
    ResultSetMeta metaInfos;
    int bpos = tableNameOrSql.indexOf(' ');
    if (bpos < 0) {
      this.tableAlias = tableNameOrSql;
      metaInfos = flashDatabase.getMetaInfos(tableNameOrSql);
      this.dataSql = "select * from " + tableNameOrSql;
    }
    else if (tableNameOrSql.lastIndexOf(' ') == bpos) {
      String tableName = tableNameOrSql.substring(0, bpos);
      this.tableAlias = tableNameOrSql.substring(bpos+1);
      metaInfos = flashDatabase.getMetaInfos(tableName);
      this.dataSql = "select * from " + tableName;
    }
    else {
      metaInfos = flashDatabase.getMetaInfos(tableNameOrSql);
      this.tableAlias = metaInfos.getFromTableAlias();
      this.dataSql = tableNameOrSql;
      this.dataSqlIsComplex = true;
    }
   
    this.columns = metaInfos.getColumns();
    this.isFirstColumnIsUnique = (metaInfos.getKeyColumnCount() == 1);
    ColumnInfo relateColumn = findColumn(joinFieldRelate, this.columns);
    if (relateColumn == null)
      throw new RuntimeException("Cann't found joinFieldRelate '"+joinFieldRelate+"' for table '"+ tableNameOrSql +"'.");
   
    this.joinFieldRelate = relateColumn.getName();
View Full Code Here

 
  // 加载表结构信息, 并加载所有主键值进行分段
  @Override
  public PartInput[] getPartInputs() {
    // 计算各表的字段信息
    ResultSetMeta metaInfos = flashDatabase.getMetaInfos(mainTableOrSql);
    ColumnInfo[] mainColumns = metaInfos.getColumns();
    this.mainIsTableName = (mainTableOrSql.indexOf(' ') < 0);
    ColumnInfo mainKeyColumnInfo;
    int tablesOffset;
    if (mainIsTableName) {
      if (metaInfos.getKeyColumnCount() != 1)
        throw new RuntimeException("Main table '"+ mainTableOrSql +"' must single key field.");
      mainKeyColumnInfo = mainColumns[0];

      ConverterJoinTable mainJTable = new ConverterJoinTable(mainTableOrSql, mainKeyColumnInfo.getName(), mainKeyColumnInfo.getName(), false, flashDatabase, false, false);
      tables = new ConverterJoinTable[1+ joinTableInfos.length];
View Full Code Here

    if ((updateColumns != null) && (mode != MODE_UPDATE))
      throw new RuntimeException("Property 'updateColumns' only support with MODE_UPDATE.");
    if ((updateColumns == null) && (mode == MODE_UPDATE))
      throw new RuntimeException("MODE_UPDATE must set property 'updateColumns'.");
   
    ResultSetMeta metaInfos = getTableMetaInfos(tableName);
    ColumnInfo[] columnInfos = metaInfos.getColumns();
    if ((mode == MODE_INSERT_INTO) || (mode == MODE_REPLACE_INTO) || (mode == MODE_INSERT_IGNORE_INTO)) {
      if (metaInfos.isAutoIncrement() && (mode == MODE_INSERT_INTO)) {
        ColumnInfo[] columnInfos2 = new ColumnInfo[columnInfos.length -1];
        System.arraycopy(columnInfos, 1, columnInfos2, 0, columnInfos2.length);
        columnInfos = columnInfos2;
      }
      StringBuilder strFields = new StringBuilder();
      StringBuilder strValues = new StringBuilder();
      for (int i=0; i <columnInfos.length; i++) {
        if (i > 0) {
          strFields.append(", ");
          strValues.append(", ");
        }
        strFields.append(columnInfos[i].getName());
        strValues.append('?');
      }
     
      this.sql = (mode == MODE_INSERT_INTO ? "INSERT INTO" : (mode == MODE_REPLACE_INTO ? "REPLACE INTO" : "INSERT IGNORE INTO")) +" "+ this.tableName
          +"("+ strFields.toString() +") VALUES ("+ strValues.toString() +")";
      this.columnInfos = columnInfos;
    }
    else if (mode == MODE_DELETE) {
      if (metaInfos.getKeyColumnCount() <= 0)
        throw new RuntimeException("Table for DELETE must have PRIMARY KEY");
      ColumnInfo[] keyColumns = new ColumnInfo[metaInfos.getKeyColumnCount()];
      System.arraycopy(columnInfos, 0, keyColumns, 0, keyColumns.length);
      StringBuilder strWhere = new StringBuilder();
      for (int i=0; i < keyColumns.length; i++) {
        if (i > 0) strWhere.append(" AND ");
        strWhere.append(keyColumns[i].getName());
        strWhere.append("=?");
      }
     
      this.sql = "DELETE FROM " + this.tableName +" WHERE "+ strWhere.toString();
      this.columnInfos = keyColumns;
    }
    else if (mode == MODE_UPDATE) {
      if (metaInfos.getKeyColumnCount() <= 0)
        throw new RuntimeException("Table for UPDATE must have PRIMARY KEY");
      ColumnInfo[] keyColumns = new ColumnInfo[metaInfos.getKeyColumnCount()];
      System.arraycopy(columnInfos, 0, keyColumns, 0, keyColumns.length);
      StringBuilder strWhere = new StringBuilder();
      for (int i=0; i < keyColumns.length; i++) {
        if (i > 0) strWhere.append(" AND ");
        strWhere.append(keyColumns[i].getName());
View Full Code Here

TOP

Related Classes of com.lingbobu.flashdb.common.ResultSetMeta

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.