Package org.apache.ws.jaxme.sqls

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


    protected Table getComposedKeyTable() {
        Table table = getPrimaryKeyTable();
        Column verNumColumn = table.newColumn("VerNum", Column.Type.INTEGER);
        assertTrue(!verNumColumn.isStringColumn());
        assertTrue(!verNumColumn.isBinaryColumn());
        Index index = table.getPrimaryKey();
        index.addColumn("VerNum");
        return table;
    }
View Full Code Here


     */
    public void testIndexNames() {
        SQLGenerator gen = getSQLGenerator();
        Table table = getBasicTable();
        for (int i = 0;  i < 10;  i++) {
            Index index = table.newIndex();
            index.addColumn("MyName");
            String s = (String) gen.getCreate(index).iterator().next();
            assertEquals("CREATE INDEX MyTable_I" + i + " ON MySchema.MyTable (MyName)", s);
        }
       
        Collection coll = gen.getCreate(schema, true);
View Full Code Here

   public Column getColumn(String pName) {
      return getColumn(new ColumnImpl.NameImpl(pName));
   }

  public Index newKey() {
      Index result = new IndexImpl(this, true, false);
      indexes.add(result);
      return result;
  }
View Full Code Here

      indexes.add(result);
      return result;
  }

  public Index newIndex() {
      Index result = new IndexImpl(this, false, false);
      indexes.add(result);
      return result;
  }
View Full Code Here

      return result;
  }

   public Index getPrimaryKey() {
      for (Iterator iter = getIndexes();  iter.hasNext()) {
         Index index = (Index) iter.next();
         if (index.isPrimaryKey()) {
            return index;
         }
      }
      return null;
   }
View Full Code Here

   public Iterator getIndexes() {
      return indexes.iterator();
   }

  public Index newPrimaryKey() {
      Index pk = getPrimaryKey();
      if (pk != null) {
         throw new IllegalStateException("A primary key is already defined on table " + getName());
      }
      Index result = new IndexImpl(this, true, true);
      indexes.add(result);
      return result;
  }
View Full Code Here

    final String mName = "readPrimaryKey";
    logger.finest(mName, "Looking for primary keys of " + pTable + "=" + pTable.getTable().getQName());
    ResultSet rs = pData.getPrimaryKeys(pTable.getCatalogName(),
                                        pTable.getSchemaName(),
                                        pTable.getTableName());
    Index primaryKey = null;
    boolean isRsClosed = false;
    try {
      while (rs.next()) {
        if (primaryKey == null) {
          primaryKey = pTable.getTable().newPrimaryKey();
        }

        String columnName = rs.getString(4);
        logger.finest(mName, "Found column " + columnName);
        primaryKey.addColumn(columnName);
      }

      isRsClosed = true;
      rs.close();
    } finally {
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

     * 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

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.