Uploaded image for project: 'Tuscany'
  1. Tuscany
  2. TUSCANY-475

Class cast exception on

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Java-M1
    • Java-SDO-M2
    • None
    • Windows XP

    Description

      I'm trying to retrieve rows from a database via the relational DAS. When I run my test prgram I get

      Exception in thread "main" java.lang.ClassCastException: org.eclipse.emf.ecore.util.EcoreEList$Dynamic incompatible with commonj.sdo.DataObject
      at org.apache.tuscany.sdo.impl.DataObjectImpl.getDataObject(DataObjectImpl.java:322)
      at org.apache.tuscany.sdo.interop.SDOInterop.testReadAndWriteRelationalDB2(SDOInterop.java)
      at org.apache.tuscany.sdo.interop.SDOInterop.main(SDOInterop.java:136)

      The code looks like.

      CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getClass().getResourceAsStream("interopconfig-db2.xml"));
      Command read = commandGroup.getCommand("all type");
      DataObject root = read.executeQuery();
      DataObject firstRow = root.getDataObject("alltype[0]");

      Now I expect to get a "firstRow" DataObject back. Indeed DataObjectImpl.getDataObject() casts the return to a DataObject

      public DataObject getDataObject(String path)

      { return (DataObject)get(path); }

      However the the DataObjectUtil.get() operation creates an Accessor and calls getAndRecycle

      public static Object get(DataObject dataObject, String path)
      {
      Property property = dataObject.getType().getProperty(path);
      if (property != null)

      { return dataObject.get(property); }

      else

      { return Accessor.create((EObject)dataObject, path).getAndRecyle(); }

      }

      getAndRecycle call get which, because I have specified a 0 index, just returns the value which happens to be of type EcoreEList$Dynamic

      So while I may have an error in my code somewhere or it might not be retrieving any data from the database a class cast exception inside of SDO doesn't seem like the correct way to tell me.

      Attachments

        1. T475.patch
          4 kB
          Kelvin Goodson

        Activity

          People

            Unassigned Unassigned
            simonslaws Simon Laws
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: