[ 
https://issues.apache.org/jira/browse/OLINGO-52?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13838609#comment-13838609
 ] 

Chandan V.A commented on OLINGO-52:
-----------------------------------

Hi Carl,
The OData JPA processor library is now enhanced to work with 
java.util.Collection. This means it can support its sub types like 
java.util.Set and java.util.List as defined in JPA 2.0 specification.

Both $expand and deep insert operations are supported now for interface types 
java.util.Set along with java.util.List. The reference scenario also has an 
example to illustrate the behavior. The property salesOrderItem is typed as 
HashSet in the SalesOrder JPA entity.

Please check if the fix works for your implementation as well.

Regards
Chandan VA

> 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: V2 1.1.0
>         Environment: Hibernate
>            Reporter: Carl J. Mosca
>            Assignee: Chandan V.A
>            Priority: Minor
>              Labels: JPA, collections, expand
>             Fix For: V2 1.1.0
>
>
> 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)

Reply via email to