Package org.apache.ws.jaxme.sqls

Examples of org.apache.ws.jaxme.sqls.Index


   * a <code>FOREIGN KEY</code> clause.</p>
   */
  protected boolean isForeignKeyPartOfCreateTable() { return false; }

  protected String createPrimaryKeyAsPartOfCreateTable(Table pTable) {
    Index index = pTable.getPrimaryKey();
    if (index == null) {
      return null;
    }
    StringBuffer sb = new StringBuffer();
    sb.append("PRIMARY KEY").append(" (");
    boolean first = true;
    for (Iterator iter = index.getColumns();  iter.hasNext()) {
      if (first) {
        first = false;
      } else {
        sb.append(", ");
      }
View Full Code Here


      sb.append(s).append(getCreate((Column) iter.next()));
      s = "," + lf + indent;
    }

    for (Iterator iter = pTable.getIndexes();  iter.hasNext()) {
      Index index = (Index) iter.next();
      String st;
      if (index.isPrimaryKey()  &&  !isPrimaryKeyUniqueIndex()) {
        if (!isPrimaryKeyPartOfCreateTable()) {
          continue;
        }
        st = createPrimaryKeyAsPartOfCreateTable(pTable);
      } else if (index.isUnique()) {
        if (!isUniqueIndexPartOfCreateTable()) {
          continue;
        }
        st = createIndexAsPartOfCreateTable(index);
      } else {
View Full Code Here

  public Collection getCreate(Table pTable, boolean pAll) {
    if (!pAll) { return getCreate(pTable); }
    List result = new ArrayList();
    result.addAll(getCreate(pTable));
    for (Iterator iter = pTable.getIndexes();  iter.hasNext()) {
      Index index = (Index) iter.next();
      if (index.isPrimaryKey() && !isPrimaryKeyUniqueIndex()) {
        if (isPrimaryKeyPartOfCreateTable()) {
          continue;
        }
      } else if (index.isUnique()) {
        if (isUniqueIndexPartOfCreateTable()) {
          continue;
        }
      } else {
        if (isNonUniqueIndexPartOfCreateTable()) {
View Full Code Here

  public Collection getDrop(Table pTable, boolean pAll) {
    if (!pAll) { return getDrop(pTable); }
    List result = new ArrayList();
    for (Iterator iter = pTable.getIndexes();  iter.hasNext()) {
      Index index = (Index) iter.next();
      result.addAll(getDrop(index));
    }
    for (Iterator iter = pTable.getForeignKeys();  iter.hasNext()) {
      ForeignKey key = (ForeignKey) iter.next();
      result.addAll(getDrop(key));
View Full Code Here

          }
          isFirstTable = false;
          columnUpdater = new VerNumIncrementer(columnNum);
        } else {
          List pkColumns = new ArrayList();
          Index primaryKey = table.getPrimaryKey();
          if (primaryKey != null) {
            for (Iterator pkIter = primaryKey.getColumns();  pkIter.hasNext()) {
              Column pkColumn = (Column) pkIter.next();
              int columnNum = -1;
              int i = 0;
              for (Iterator colIter = table.getColumns();  colIter.hasNext();  i++) {
                Column colIterColumn = (Column) colIter.next();
View Full Code Here

        mtName.setLength(60);
        BinaryColumn mtSig = (BinaryColumn) mt.newColumn("SIG", Column.Type.BINARY);
        mtSig.setLength(16);
        mt.newColumn("DATE", Column.Type.DATE);

        Index primaryKey = mt.newPrimaryKey();
        primaryKey.addColumn(mtId);
        primaryKey.addColumn(mtVer);
        mainTable = mt;
     }
     return mainTable;
  }
View Full Code Here

      stAddress.setLength(60);
      StringColumn stEmail = (StringColumn) st.newColumn("EMAIL", Column.Type.VARCHAR);
      stEmail.setLength(60);
      stEmail.setNullable(true);

      Index primaryKey = st.newPrimaryKey();
      primaryKey.addColumn(stId);

      ForeignKey foreignKey = st.newForeignKey(getMainTable());
      foreignKey.addColumnLink(stMtId, getMainTable().getColumn("ID"));
      foreignKey.addColumnLink(stMtVer, getMainTable().getColumn("VER"));
View Full Code Here

      mtName.setLength(60);
      BinaryColumn mtSig = (BinaryColumn) mt.newColumn("SIG", Column.Type.BINARY);
      mtSig.setLength(16);
      mt.newColumn("DATE", Column.Type.DATE);
     
      Index primaryKey = mt.newPrimaryKey();
      primaryKey.addColumn(mtId);
      primaryKey.addColumn(mtVer);
      mainTable = mt;
    }
    return mainTable;
  }
View Full Code Here

      stAddress.setLength(60);
      StringColumn stEmail = (StringColumn) st.newColumn("EMAIL", Column.Type.VARCHAR);
      stEmail.setLength(60);
      stEmail.setNullable(true);
     
      Index primaryKey = st.newPrimaryKey();
      primaryKey.addColumn(stId);
     
      ForeignKey foreignKey = st.newForeignKey(getMainTable());
      foreignKey.addColumnLink(stMtId, getMainTable().getColumn("ID"));
      foreignKey.addColumnLink(stMtVer, getMainTable().getColumn("VER"));
     
View Full Code Here

   
    /** <p>Creates a table with primary key</p>
     */
    protected Table getPrimaryKeyTable() {
        Table table = getBasicTable();
        Index index = table.newPrimaryKey();
        index.addColumn("MyIndex");
        return table;
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.sqls.Index

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.