[jira] Created: (CAY-1117) Class Cast Exception in SQLServerMergerFactory from AutoAdapter to SQLServerAdapter

From: Laurentiu Cocanu (JIRA) ("Laurentiu)
Date: Wed Oct 08 2008 - 07:26:11 EDT

  • Next message: Tore Halset (JIRA): "[jira] Closed: (CAY-1117) Class Cast Exception in SQLServerMergerFactory from AutoAdapter to SQLServerAdapter"

    Class Cast Exception in SQLServerMergerFactory from AutoAdapter to SQLServerAdapter
    -----------------------------------------------------------------------------------

                     Key: CAY-1117
                     URL: https://issues.apache.org/cayenne/browse/CAY-1117
                 Project: Cayenne
              Issue Type: Bug
              Components: Cayenne Core Library
        Affects Versions: 2.0 [STABLE]
             Environment: Windows XP, 1.6.0_07 by Sun Microsystems Inc., Microsoft SQL Server
                Reporter: Laurentiu Cocanu
                Assignee: Andrus Adamchik

    In cayenne/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java, the following method

     ..verride
        public MergerToken createSetNotNullToDb(DbEntity entity, final
    DbAttribute column) {

            return new SetNotNullToDb(entity, column) {

               ..verride
                public List<String> createSql(DbAdapter adapter) {
                    StringBuffer sqlBuffer = new StringBuffer();

                    sqlBuffer.append("ALTER TABLE ");
                    sqlBuffer.append(getEntity().getFullyQualifiedName());
                    sqlBuffer.append(" ALTER COLUMN ");

                    SQLServerAdapter sqladapter = (SQLServerAdapter) adapter;
                    sqladapter.createTableAppendColumn(sqlBuffer, column);

                    return Collections.singletonList(sqlBuffer.toString());
                }

            };
        }

    the cast SQLServerAdapter sqladapter = (SQLServerAdapter) adapter; will raise a Class Cast Exception.
    A possible fix could be eliminating this cast as createTableAppendColumn method is defined in DbAdapter interface, so the cast is useless.
    See http://www.nabble.com/Upcast-problems-w-SQLServerMergerFactory-and-AutoAdapter-td19664724.html (the patch is known but not implemented yet)

    -- 
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
    



    This archive was generated by hypermail 2.0.0 : Wed Oct 08 2008 - 07:26:46 EDT