Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Java-M1
-
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)
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.