You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Carl J. Mosca (JIRA)" <ji...@apache.org> on 2013/10/30 14:07:25 UTC

[jira] [Created] (OLINGO-52) expand collection issue - Set support

Carl J. Mosca created OLINGO-52:
-----------------------------------

             Summary: expand collection issue - Set support
                 Key: OLINGO-52
                 URL: https://issues.apache.org/jira/browse/OLINGO-52
             Project: Olingo
          Issue Type: Bug
          Components: odata2-jpa
    Affects Versions: 1.1.0
         Environment: Hibernate
            Reporter: Carl J. Mosca
            Priority: Minor


We have a model which employs Sets.  The JPAExpandCallback seems to be expecting Lists for collections.

The newly discovered "odata-debug" made finding this issue very easy. :)

A diff of the code changes for a quick fix are below.  Because I ran into this previously elsewhere, I wonder if a cleaner way to handle the collections has already been added somewhere in the code base.

@@ -100,8 +104,13 @@
     List<EdmNavigationProperty> currentNavPropertyList = null;
     EdmNavigationProperty currentNavigationProperty = context.getNavigationProperty();
     try {
-      @SuppressWarnings({ "unchecked" })
-      List<Object> listOfItems = (List<Object>) inlinedEntry.get(context.getNavigationProperty().getName());
+            List<Object> listOfItems = null;
+            if (inlinedEntry.get(context.getNavigationProperty().getName()) instanceof Set) {
+                listOfItems = new ArrayList<Object>();
+                listOfItems.addAll((Set) inlinedEntry.get(context.getNavigationProperty().getName()));
+            } else {
+                listOfItems = (List<Object>) inlinedEntry.get(context.getNavigationProperty().getName());
+            }
       if (nextEntitySet == null) {
         nextEntitySet = context.getSourceEntitySet().getRelatedEntitySet(currentNavigationProperty);
       }




--
This message was sent by Atlassian JIRA
(v6.1#6144)