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

Michael Bolz commented on OLINGO-497:
-------------------------------------

Hi [~kiransg],

I agree with you that {{LinkedHashMap}} has to be used in the implementation.
For the interface I personally prefer to use only {{Map}} so that an 
implementation is independent what sort of an ordered map is returned (as 
example {{LinkedHashMap}}).
Hence I suggest to change the interface to {{Map}} and enhance the 
{{ODataExpressionParser}} to use a {{LinkedHashMap}} in line _381_.

What do you think?

Kind regards,
Michael

{code}
  public static HashMap<String, String> 
parseKeyPropertiesToJPAOrderByExpression(
      final List<EdmProperty> edmPropertylist, final String tableAlias) throws 
ODataJPARuntimeException {
    LinkedHashMap<String, String> orderByMap = new LinkedHashMap<String, 
String>();
    String propertyName = null;
    for (EdmProperty edmProperty : edmPropertylist) {
      try {
        EdmMapping mapping = edmProperty.getMapping();
        if (mapping != null && mapping.getInternalName() != null) {
          propertyName = mapping.getInternalName();// For embedded/complex keys
        } else {
          propertyName = edmProperty.getName();
        }
      } catch (EdmException e) {
        throw 
ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),
 e);
      }
      orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + 
propertyName, EMPTY);
    }
    return orderByMap;
  }
{code}

> JPQLSelectContextView should use LinkedHashMap for OrderBy
> ----------------------------------------------------------
>
>                 Key: OLINGO-497
>                 URL: https://issues.apache.org/jira/browse/OLINGO-497
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.0
>            Reporter: Kiran G
>            Assignee: Michael Bolz
>
> JPQLSelectContextView has a method to getOrderByCollection.
> {code}
> public HashMap<String, String> getOrderByCollection();
> {code}
> This method really should return LinkedHashMap to preserve the order of the  
> $orderby's specified in the url. With the HashMap the orderbys are now being 
> applied in a random order in the query.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to