commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model Table.betwixt Table.java
Date Mon, 28 Oct 2002 19:42:32 GMT
jstrachan    2002/10/28 11:42:32

  Modified:    sql/src/java/org/apache/commons/sql/io JdbcModelReader.java
               sql/src/test/org/apache/commons/sql/io
                        AbstractTestJdbcModelReader.java
               sql/src/test-input datamodel.xml
               sql/src/java/org/apache/commons/sql/model Table.betwixt
                        Table.java
  Added:       sql/src/test/org/apache/commons/sql/task
                        TestJdbcToSchemaTask.java
               sql/src/test/org/apache/commons/sql/io
                        TestAxionJdbcModelReader.java
  Removed:     sql/src/test/org/apache/commons/sql/task
                        JdbcToSchemaTaskTest.java
  Log:
  * added a findColumn() helper method on Table.
  
  * added Eric's Axion unit test case.  Also improved this test case to check for some flags
being set etc.
  
  * got the TestJdbcToSchemaTask working.
  
  All unit test cases are now working; though we should fix the @todo issue in the JdbcModelReader
test case for the isRequired() flag not being reverse engineered
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/sql/src/test/org/apache/commons/sql/task/TestJdbcToSchemaTask.java
  
  Index: TestJdbcToSchemaTask.java
  ===================================================================
  /*
   * $Header: $
   * $Revision: $
   * $Date: $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   */
  
  package org.apache.commons.sql.task;
  
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.FileWriter;
  import java.io.PrintWriter;
  import java.sql.Connection;
  import java.sql.DatabaseMetaData;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.Types;
  import java.sql.SQLException;
  import java.util.Hashtable;
  import java.util.List;
  import java.util.Vector;
  import java.util.Collection;
  import java.util.Iterator;
  
  import junit.framework.*;
  
  import org.apache.commons.sql.io.DatabaseWriter;
  import org.apache.commons.sql.io.JdbcModelReader;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  
  /**
   * A JUnit test for JdbcToSchemaTask.java
   *
   * @author <a href="mailto:drfish@cox.net">J. Russell Smyth</a>
   * @version $Revision: $
   */
  public class TestJdbcToSchemaTask extends TestCase {
      
      public TestJdbcToSchemaTask(java.lang.String testName) {
          super(testName);
      }
      
      public static void main(java.lang.String[] args) {
          junit.textui.TestRunner.run(suite());
      }
      
      public static Test suite() {
          TestSuite suite = new TestSuite(TestJdbcToSchemaTask.class);
          return suite;
      }
      
      
      /** Test of execute method, of class test.JdbcToSchemaTask. */
      public void testExecute() {
          System.out.println("testExecute");
          JdbcToSchemaTask t = createTask();
          t.execute();
      }
      
      
      protected JdbcToSchemaTask createTask() {
          JdbcToSchemaTask task = new JdbcToSchemaTask();
          task.setDbDriver("org.axiondb.jdbc.AxionDriver");
          task.setDbUrl("jdbc:axiondb:diskdb:target/axiondb");
          task.setDbSchema("TEST");
          task.setOutputFile("target/test.xml");
          return task;
      }
      
      
  }
  
  
  
  1.2       +97 -76    jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/io/JdbcModelReader.java
  
  Index: JdbcModelReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/io/JdbcModelReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JdbcModelReader.java	28 Oct 2002 16:16:19 -0000	1.1
  +++ JdbcModelReader.java	28 Oct 2002 19:42:31 -0000	1.2
  @@ -70,6 +70,10 @@
   import java.util.List;
   import java.util.Vector;
   import java.util.Iterator;
  +
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   import org.apache.commons.sql.model.*;
   
   /**
  @@ -80,6 +84,9 @@
    */
   public class JdbcModelReader {
   
  +    /** The Log to which logging calls will be made. */
  +    private static final Log log = LogFactory.getLog( JdbcModelReader.class );
  +
       Connection connection = null;
       String catalog = null;
       String schema = null;
  @@ -396,13 +403,20 @@
           ResultSet parts = null;
           try {
               parts = dbmd.getPrimaryKeys(catalog, schema, tableName);
  -            while (parts.next()) {
  -                pk.add(parts.getString(4));
  -            }
           }
  -        finally {
  -            if (parts != null) {
  -                parts.close();
  +        catch (SQLException e) {
  +            log.trace("database does not support getPrimaryKeys()", e);
  +        }
  +        if (parts != null) {
  +            try{
  +                while (parts.next()) {
  +                    pk.add(parts.getString(4));
  +                }
  +            }
  +            finally {
  +                if (parts != null) {
  +                    parts.close();
  +                }
               }
           }
           return pk;
  @@ -425,79 +439,86 @@
           ForeignKey currFk = null;
           try {
               foreignKeys = dbmd.getImportedKeys(catalog, schema, tableName);
  -            while (foreignKeys.next()) {
  -                //primary key table catalog being imported (may be null)
  -                String pkCat = foreignKeys.getString("PKTABLE_CAT");
  -                //primary key table schema being imported (may be null)
  -                String pkSchema = foreignKeys.getString("PKTABLE_SCHEM");
  -                //primary key table name being imported
  -                String pkTable = foreignKeys.getString("PKTABLE_NAME");
  -                //primary key column name being imported
  -                String pkColumn = foreignKeys.getString("PKCOLUMN_NAME");
  -                // foreign key table catalog (may be null)
  -                String fkCat = foreignKeys.getString("FKTABLE_CAT");
  -                // foreign key table schema (may be null)
  -                String fkSchema = foreignKeys.getString("FKTABLE_SCHEM");
  -                // foreign key table name
  -                String fkTable = foreignKeys.getString("FKTABLE_NAME");
  -                // foreign key column name
  -                String fkColumn = foreignKeys.getString("FKCOLUMN_NAME");
  -                /* sequence number within a foreign key */
  -                short keySequence = foreignKeys.getShort("KEY_SEQ");
  -                /*What happens to a foreign key when the primary key is updated */
  -                short updateRule = foreignKeys.getShort("UPDATE_RULE");
  -                //importedNoAction - do not allow update of primary 
  -                //               key if it has been imported
  -                //importedKeyCascade - change imported key to agree 
  -                //               with primary key update
  -                //importedKeySetNull - change imported key to NULL if its primary key has
been updated
  -                //importedKeySetDefault - change imported key to default values 
  -                //               if its primary key has been updated
  -                //importedKeyRestrict - same as importedKeyNoAction 
  -                //                                 (for ODBC 2.x compatibility)
  -                // What happens to the foreign key when primary is deleted.
  -                short deleteRule = foreignKeys.getShort("DELETE_RULE");
  -                //importedKeyNoAction - do not allow delete of primary 
  -                //               key if it has been imported
  -                //importedKeyCascade - delete rows that import a deleted key
  -                //importedKeySetNull - change imported key to NULL if 
  -                //               its primary key has been deleted
  -                //importedKeyRestrict - same as importedKeyNoAction 
  -                //                                 (for ODBC 2.x compatibility)
  -                //importedKeySetDefault - change imported key to default if 
  -                //               its primary key has been deleted
  -                /*foreign key name (may be null)*/
  -                String fkName = foreignKeys.getString("FK_NAME");
  -                /*primary key name (may be null)*/
  -                String pkName = foreignKeys.getString("PK_NAME");
  -                /*can the evaluation of foreign key constraints be deferred until commit*/
  -                short deferrablity = foreignKeys.getShort("DEFERRABILITY");
  -                //importedKeyInitiallyDeferred - see SQL92 for definition
  -                //importedKeyInitiallyImmediate - see SQL92 for definition 
  -                //importedKeyNotDeferrable - see SQL92 for definition                
  -                if (!pkTable.equals(prevPkTable)) {
  -                    if (currFk != null) {
  -                        fks.add(currFk);
  +        }
  +        catch (SQLException e) {
  +            log.trace("database does not support getImportedKeys()", e);
  +        }
  +        if (foreignKeys != null) {
  +            try {
  +                while (foreignKeys.next()) {
  +                    //primary key table catalog being imported (may be null)
  +                    String pkCat = foreignKeys.getString("PKTABLE_CAT");
  +                    //primary key table schema being imported (may be null)
  +                    String pkSchema = foreignKeys.getString("PKTABLE_SCHEM");
  +                    //primary key table name being imported
  +                    String pkTable = foreignKeys.getString("PKTABLE_NAME");
  +                    //primary key column name being imported
  +                    String pkColumn = foreignKeys.getString("PKCOLUMN_NAME");
  +                    // foreign key table catalog (may be null)
  +                    String fkCat = foreignKeys.getString("FKTABLE_CAT");
  +                    // foreign key table schema (may be null)
  +                    String fkSchema = foreignKeys.getString("FKTABLE_SCHEM");
  +                    // foreign key table name
  +                    String fkTable = foreignKeys.getString("FKTABLE_NAME");
  +                    // foreign key column name
  +                    String fkColumn = foreignKeys.getString("FKCOLUMN_NAME");
  +                    /* sequence number within a foreign key */
  +                    short keySequence = foreignKeys.getShort("KEY_SEQ");
  +                    /*What happens to a foreign key when the primary key is updated */
  +                    short updateRule = foreignKeys.getShort("UPDATE_RULE");
  +                    //importedNoAction - do not allow update of primary 
  +                    //               key if it has been imported
  +                    //importedKeyCascade - change imported key to agree 
  +                    //               with primary key update
  +                    //importedKeySetNull - change imported key to NULL if its primary key
has been updated
  +                    //importedKeySetDefault - change imported key to default values 
  +                    //               if its primary key has been updated
  +                    //importedKeyRestrict - same as importedKeyNoAction 
  +                    //                                 (for ODBC 2.x compatibility)
  +                    // What happens to the foreign key when primary is deleted.
  +                    short deleteRule = foreignKeys.getShort("DELETE_RULE");
  +                    //importedKeyNoAction - do not allow delete of primary 
  +                    //               key if it has been imported
  +                    //importedKeyCascade - delete rows that import a deleted key
  +                    //importedKeySetNull - change imported key to NULL if 
  +                    //               its primary key has been deleted
  +                    //importedKeyRestrict - same as importedKeyNoAction 
  +                    //                                 (for ODBC 2.x compatibility)
  +                    //importedKeySetDefault - change imported key to default if 
  +                    //               its primary key has been deleted
  +                    /*foreign key name (may be null)*/
  +                    String fkName = foreignKeys.getString("FK_NAME");
  +                    /*primary key name (may be null)*/
  +                    String pkName = foreignKeys.getString("PK_NAME");
  +                    /*can the evaluation of foreign key constraints be deferred until commit*/
  +                    short deferrablity = foreignKeys.getShort("DEFERRABILITY");
  +                    //importedKeyInitiallyDeferred - see SQL92 for definition
  +                    //importedKeyInitiallyImmediate - see SQL92 for definition 
  +                    //importedKeyNotDeferrable - see SQL92 for definition             
  
  +                    if (!pkTable.equals(prevPkTable)) {
  +                        if (currFk != null) {
  +                            fks.add(currFk);
  +                        }
  +                        currFk = new ForeignKey();
  +                        currFk.setForeignTable(pkTable);
  +                        prevPkTable = pkTable;
                       }
  -                    currFk = new ForeignKey();
  -                    currFk.setForeignTable(pkTable);
  -                    prevPkTable = pkTable;
  -                }
  -                Reference ref = new Reference();
  -                ref.setForeign(pkColumn);
  -                ref.setLocal(fkColumn);
  -                currFk.addReference(ref);
  -            }
  -            if (currFk != null) {
  -                fks.add(currFk);
  -                currFk = null;
  +                    Reference ref = new Reference();
  +                    ref.setForeign(pkColumn);
  +                    ref.setLocal(fkColumn);
  +                    currFk.addReference(ref);
  +                }
  +                if (currFk != null) {
  +                    fks.add(currFk);
  +                    currFk = null;
  +                }
               }
  -            return fks;
  -        }
  -        finally {
  -            if (foreignKeys != null) {
  -                foreignKeys.close();
  +            finally {
  +                if (foreignKeys != null) {
  +                    foreignKeys.close();
  +                }
               }
           }
  +        return fks;
       }
   }
  
  
  
  1.2       +35 -3     jakarta-commons-sandbox/sql/src/test/org/apache/commons/sql/io/AbstractTestJdbcModelReader.java
  
  Index: AbstractTestJdbcModelReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/test/org/apache/commons/sql/io/AbstractTestJdbcModelReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractTestJdbcModelReader.java	28 Oct 2002 18:40:19 -0000	1.1
  +++ AbstractTestJdbcModelReader.java	28 Oct 2002 19:42:31 -0000	1.2
  @@ -191,16 +191,48 @@
   
           }
   
  -        Table bookTable = database.findTable("book");
  +        Table authorTable = testDatabase.findTable("author");
  +        Column authorColumn = authorTable.findColumn("organisation");
  +        
  +        assertTrue("organisation column is not a primary key", !authorColumn.isPrimaryKey());
  +        assertTrue("organisation column is not auto inc", !authorColumn.isAutoIncrement());
  +        assertTrue("organisation column is not required", !authorColumn.isRequired());
  +
  +
  +        Table bookTable = testDatabase.findTable("book");
           Column bookColumn = bookTable.findColumn("book_id");
  +        
  +        if (supportsPrimaryKeyMetadata()) {
  +            assertTrue("book_id column is primary key", bookColumn.isPrimaryKey());
  +        }            
  +        
  +        if (supportsAutoIncrement()) {
  +            assertTrue("book_id column is auto inc", bookColumn.isAutoIncrement());
  +        }
  +            
  +        /** @todo uncomment when this works!        
  +         * 
           assertTrue("book_id column is required", bookColumn.isRequired());
  -        assertTrue("book_id column is auto inc", bookColumn.isAutoIncrement());
  -        assertTrue("book_id column is primary key", bookColumn.isPrimaryKey());
  +        */
       }
   
       // Implementation methods
       //-------------------------------------------------------------------------
   
  +    /**
  +     * @return true if this database test case should test for primary key meta data
  +     */
  +    protected boolean supportsPrimaryKeyMetadata() {
  +        return true;
  +    }
  +    
  +    /**
  +     * @return true if we should test for auto-increment columns
  +     */
  +    protected boolean supportsAutoIncrement() {
  +        return false;
  +    }
  +    
       public abstract void doImportForeignKeys(Table srcTable, Table testTable);
       public abstract void doImportPrimaryKeyColumns(
           Table srcTable,
  
  
  
  1.1                  jakarta-commons-sandbox/sql/src/test/org/apache/commons/sql/io/TestAxionJdbcModelReader.java
  
  Index: TestAxionJdbcModelReader.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/CompilableTag.java,v
1.5 2002/05/17 15:18:12 jstrachan Exp $
   * $Revision: 1.5 $
   * $Date: 2002/05/17 15:18:12 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: CompilableTag.java,v 1.5 2002/05/17 15:18:12 jstrachan Exp $
   */
  package org.apache.commons.sql.io;
  
  import javax.sql.DataSource;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.apache.commons.sql.model.Table;
  
  /**
   * JdbcModelReader test harness for the Axion database
   *
   * @author <a href="mailto:dep4b@yahoo.com">Eric Pugh</a>
   * @version $Revision: 1.3 $
   */
  public class TestAxionJdbcModelReader extends AbstractTestJdbcModelReader {
  
      /** The Log to which logging calls will be made. */
      private static final Log log =
          LogFactory.getLog(TestAxionJdbcModelReader.class);
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      /**
       * A unit test suite for JUnit
       */
      public static Test suite() {
          return new TestSuite(TestAxionJdbcModelReader.class);
      }
  
      public void doImportForeignKeys(Table srcTable, Table testTable) {
          // Axion doesn't support importing forign keys
          assertTrue(
              "No FK imported from Axion",
              testTable.getForeignKeys().size() == 0);
      }
  
      public void doImportPrimaryKeyColumns(Table srcTable, Table testTable) {
          // Axion doesn't support importing primary keys
          assertTrue(
              "No PK imported from Axion",
              testTable.getPrimaryKeyColumns().size() == 0);
      }
  
      /**
       * Constructor for the TestAxionJdbcModelReader object
       *
       * @param testName
       */
      public TestAxionJdbcModelReader(String testName) {
          super(testName);
      }
  
      protected boolean supportsPrimaryKeyMetadata() {
          return false;
      }
      
      protected String getDatabaseType() {
          return "axion";
      }
  
      protected DataSource createDataSource() throws Exception {
          return createDataSource(
              "org.axiondb.jdbc.AxionDriver",
              "jdbc:axiondb:diskdb:target/axiondb");
      }
  }
  
  
  
  1.6       +1 -0      jakarta-commons-sandbox/sql/src/test-input/datamodel.xml
  
  Index: datamodel.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/test-input/datamodel.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- datamodel.xml	23 Sep 2002 16:57:27 -0000	1.5
  +++ datamodel.xml	28 Oct 2002 19:42:31 -0000	1.6
  @@ -9,6 +9,7 @@
     <table name="author">
       <column name="author_id" type="INTEGER" primaryKey="true" required="true"/>
       <column name="name" type="VARCHAR" size="50" required="true"/>
  +    <column name="organisation" type="VARCHAR" size="50" required="false"/>
   	</table>
   
     <!-- =================================================== -->
  
  
  
  1.2       +1 -0      jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model/Table.betwixt
  
  Index: Table.betwixt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model/Table.betwixt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Table.betwixt	28 Oct 2002 16:14:15 -0000	1.1
  +++ Table.betwixt	28 Oct 2002 19:42:32 -0000	1.2
  @@ -2,6 +2,7 @@
   <info>
     <element>
       <hide property="primaryKeyColumns"/>
  +    <hide property="autoIncrementColumn"/>
       <addDefaults/>
     </element>
   </info>
  
  
  
  1.8       +20 -0     jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/model/Table.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Table.java	23 Oct 2002 10:17:16 -0000	1.7
  +++ Table.java	28 Oct 2002 19:42:32 -0000	1.8
  @@ -221,6 +221,26 @@
       }
       
       /**
  +     * Finds the table with the specified name, using case insensitive matching.
  +     * Note that this method is not called getColumn(String) to avoid introspection 
  +     * problems.
  +     */
  +    public Column findColumn(String name)
  +    {
  +        for (Iterator iter = getColumns().iterator(); iter.hasNext(); ) 
  +        {
  +            Column column = (Column) iter.next();
  +            
  +            // column names are typically case insensitive
  +            if (column.getName().equalsIgnoreCase( name )) 
  +            {
  +                return column;
  +            }
  +        }
  +        return null;
  +    }
  +
  +    /**
        * @return a List of primary key columns or an empty list if there are no
        * primary key columns for this Table
        */    
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message