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

kieuanhvu edited comment on OFBIZ-5701 at 8/18/14 6:13 PM:
-----------------------------------------------------------

Hi, Jacques Le Roux, my use case as following:          
               EntityFindOptions options = new EntityFindOptions(); // Line 1
                options.setDistinct(true); // Line 2
                options.setMaxRows(viewSize * (viewIndex + 1));//  viewSize = 
10, viewIndex = 0         
                lowIndex = viewIndex * viewSize + 1;
                highIndex = (viewIndex + 1) * viewSize;
                try {
                        EntityListIterator partyListIt = 
delegator.find("PartyRoleAndPartyDetail", 
                                        
EntityCondition.makeCondition(conditions, EntityOperator.AND), null, null, 
UtilMisc.toList("createdDate DESC"), options);
                        List<GenericValue> partyList = 
partyListIt.getPartialList(lowIndex, viewSize); // Line 9
                        int partyListSize = 
partyListIt.getResultsSizeAfterPartialList();  // Line 10
                        partyListIt.close();
                        if(highIndex > partyListSize){
                                highIndex = partyListSize;
                        }
                       /*.....*/
               }catch(GenericEntityException e){
               }

If I delete line 2 in my code, the partyListSize variable will have result as 
my expected (In my specific case, partyListSize = 19)
If I don't delete line 2, the partyListSize variable will equals 1, but size of 
partyList, in line 9, is 10 (because the viewSize = 10).


was (Author: kieuanhvu):
Hi, Jacques Le Roux, my use case as following:          
               EntityFindOptions options = new EntityFindOptions(true, 
EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, 
true); // Line 1
                options.setDistinct(true); // Line 2
                options.setMaxRows(viewSize * (viewIndex + 1));//  viewSize = 
10, viewIndex = 0         
                lowIndex = viewIndex * viewSize + 1;
                highIndex = (viewIndex + 1) * viewSize;
                try {
                        EntityListIterator partyListIt = 
delegator.find("PartyRoleAndPartyDetail", 
                                        
EntityCondition.makeCondition(conditions, EntityOperator.AND), null, null, 
UtilMisc.toList("createdDate DESC"), options);
                        List<GenericValue> partyList = 
partyListIt.getPartialList(lowIndex, viewSize); // Line 9
                        int partyListSize = 
partyListIt.getResultsSizeAfterPartialList();  // Line 10
                        partyListIt.close();
                        if(highIndex > partyListSize){
                                highIndex = partyListSize;
                        }
                       /*.....*/
               }catch(GenericEntityException e){
               }

If I delete line 2 in my code, the partyListSize variable will have result as 
my expected (In my specific case, partyListSize = 19)
If I don't delete line 2, the partyListSize variable will equals 1, but size of 
partyList, in line 9, is 10 (because the viewSize = 10).

> Bug SQL Count Distinct command in GenericDAO.java 
> --------------------------------------------------
>
>                 Key: OFBIZ-5701
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5701
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: kieuanhvu
>         Attachments: GenericDAO.java.patch, SQLDistinctGenericDAO.diff, 
> SQLDistinctGenericDAO.diff
>
>
> I have encounter the problem is: How can ofbiz framework count distinct for 
> all selected fields in query function of delegator? Although 
> EntityFindOptions.setDistinct(true) and the selected fields are all field, 
> the ofbiz framework always count distinct follow only one field.
> I have resolved problem as my attact file



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to