2222import java .util .List ;
2323import java .util .Map ;
2424import java .util .Objects ;
25- import java .util .stream .Collectors ;
2625
2726import javax .annotation .PostConstruct ;
2827import javax .inject .Inject ;
@@ -72,10 +71,10 @@ public class BackupDaoImpl extends GenericDaoBase<BackupVO, Long> implements Bac
7271 BackupDetailsDao backupDetailsDao ;
7372
7473 private SearchBuilder <BackupVO > backupSearch ;
75- private SearchBuilder <BackupVO > backupVmSearchInZone ;
7674 private GenericSearchBuilder <BackupVO , Long > CountBackupsByAccount ;
7775 private GenericSearchBuilder <BackupVO , SumCount > CalculateBackupStorageByAccount ;
7876 private SearchBuilder <BackupVO > ListBackupsByVMandIntervalType ;
77+ private GenericSearchBuilder <BackupVO , Long > backupVmSearchInZone ;
7978
8079 public BackupDaoImpl () {
8180 }
@@ -89,10 +88,10 @@ protected void init() {
8988 backupSearch .and ("zone_id" , backupSearch .entity ().getZoneId (), SearchCriteria .Op .EQ );
9089 backupSearch .done ();
9190
92- backupVmSearchInZone = createSearchBuilder ();
93- backupVmSearchInZone .and ( "zone_id" , backupSearch . entity ().getZoneId (), SearchCriteria . Op . EQ );
94- backupVmSearchInZone .select ( "vm_id " , SearchCriteria . Func . DISTINCT , backupVmSearchInZone .entity ().getVmId () );
95- backupSearch .done ();
91+ backupVmSearchInZone = createSearchBuilder (Long . class );
92+ backupVmSearchInZone .select ( null , SearchCriteria . Func . DISTINCT , backupVmSearchInZone . entity ().getVmId () );
93+ backupVmSearchInZone .and ( "zone_id " , backupVmSearchInZone .entity ().getZoneId (), SearchCriteria . Op . EQ );
94+ backupVmSearchInZone .done ();
9695
9796 CountBackupsByAccount = createSearchBuilder (Long .class );
9897 CountBackupsByAccount .select (null , SearchCriteria .Func .COUNT , null );
@@ -275,10 +274,9 @@ public void saveDetails(BackupVO backup) {
275274
276275 @ Override
277276 public List <Long > listVmIdsWithBackupsInZone (Long zoneId ) {
278- SearchCriteria <BackupVO > sc = backupVmSearchInZone .create ();
277+ SearchCriteria <Long > sc = backupVmSearchInZone .create ();
279278 sc .setParameters ("zone_id" , zoneId );
280- List <BackupVO > backups = customSearch (sc , null );
281- return backups .stream ().map (BackupVO ::getVmId ).collect (Collectors .toList ());
279+ return customSearchIncludingRemoved (sc , null );
282280 }
283281
284282 @ Override
0 commit comments