You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Benjamin Jugl (JIRA)" <ji...@apache.org> on 2018/12/12 13:10:00 UTC

[jira] [Updated] (OFBIZ-10298) Fluent API Bug in getFieldList()

     [ https://issues.apache.org/jira/browse/OFBIZ-10298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Jugl updated OFBIZ-10298:
----------------------------------
    Description: 
In EntityQuery the method getFieldList() uses the class variable {{distinct}} to decide if the list of genericValues should be stored in a set to eliminate duplicate values. This variable is set by the function distinct() and normally it should only be used for the sql statement. But here the flag gets mistreated since, if the list of values was ordered because of orderBy(), the order of values gets lost by putting them into a set. To summarize, the following statement:

{{....orderBy("...").dinstinct().getFieldLlist("...");}}

does not produce an ordered list.

Replacing the HashSet by a LinkedHashSet fixes this issue.

  was:
In EntityQuery the method getFieldList() uses the class variable {{distinct}} to decide if the list of genericValues should be stored in a set to eliminate duplicate values. This variable is set by the function distinct() and normally it should only be used for the sql statement. But here the flag gets mistreated since, if the list of values was ordered because of orderBy(), the order of values gets lost by putting them into a set. To summarize, the following statement:

{{....orderBy("...").dinstinct().getFieldLlist("...");}}

does not produce an ordered list.

This can be fixed, for example, by extending the signature of getFieldList by a boolean parameter which decides if the list needs distinct values.


> Fluent API Bug in getFieldList()
> --------------------------------
>
>                 Key: OFBIZ-10298
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10298
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Benjamin Jugl
>            Priority: Minor
>         Attachments: OFBIZ-10298_org.apache.ofbiz.entity.util_distinct_to_primitive.patch, OFBIZ-10298_org.apache.ofbiz.entity.util_getFieldList_Fix.patch
>
>
> In EntityQuery the method getFieldList() uses the class variable {{distinct}} to decide if the list of genericValues should be stored in a set to eliminate duplicate values. This variable is set by the function distinct() and normally it should only be used for the sql statement. But here the flag gets mistreated since, if the list of values was ordered because of orderBy(), the order of values gets lost by putting them into a set. To summarize, the following statement:
> {{....orderBy("...").dinstinct().getFieldLlist("...");}}
> does not produce an ordered list.
> Replacing the HashSet by a LinkedHashSet fixes this issue.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)