Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1117

Class Cast Exception in SQLServerMergerFactory from AutoAdapter to SQLServerAdapter

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0 branch
    • 3.0
    • Core Library
    • None
    • Windows XP, 1.6.0_07 by Sun Microsystems Inc., Microsoft SQL Server

    Description

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

      @Override
      public MergerToken createSetNotNullToDb(DbEntity entity, final
      DbAttribute column) {

      return new SetNotNullToDb(entity, column) {

      @Override
      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)

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            halset Tore Halset
            laurentiu Laurentiu Cocanu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment