shwstppr commented on code in PR #8362:
URL: https://github.com/apache/cloudstack/pull/8362#discussion_r1489990527


##########
server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java:
##########
@@ -679,4 +680,30 @@ public List<UserVmJoinVO> newUserVmView(VirtualMachine... 
vms) {
         return searchByIds(vmIdSet.toArray(new Long[vmIdSet.size()]));
     }
 
+    @Override
+    public List<UserVmJoinVO> 
listByAccountServiceOfferingTemplateAndNotInState(long accountId, List<State> 
states,
+            List<Long> offeringIds, List<Long> templateIds) {
+        SearchBuilder<UserVmJoinVO> userVmSearch = createSearchBuilder();
+        userVmSearch.and("accountId", userVmSearch.entity().getAccountId(), 
Op.EQ);
+        userVmSearch.and("serviceOfferingId", 
userVmSearch.entity().getServiceOfferingId(), Op.IN);
+        userVmSearch.and("templateId", userVmSearch.entity().getTemplateId(), 
Op.IN);
+        userVmSearch.and("state", userVmSearch.entity().getState(), 
SearchCriteria.Op.NIN);
+        userVmSearch.and("displayVm", userVmSearch.entity().isDisplayVm(), 
Op.EQ);
+        userVmSearch.groupBy(userVmSearch.entity().getId()); // select distinct

Review Comment:
   Without group by it will return same VM entry for different nics, etc and 
may need handling in java



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to