2525import java .util .List ;
2626import java .util .Map ;
2727
28- import com .cloud .dc .VsphereStoragePolicyVO ;
29- import com .cloud .dc .dao .VsphereStoragePolicyDao ;
30- import com .cloud .user .AccountManager ;
31- import com .cloud .utils .db .TransactionLegacy ;
3228import org .apache .cloudstack .annotation .AnnotationService ;
3329import org .apache .cloudstack .annotation .dao .AnnotationDao ;
34- import com .cloud .storage .DiskOfferingVO ;
3530import org .apache .cloudstack .api .ApiConstants ;
3631import org .apache .cloudstack .api .response .ServiceOfferingResponse ;
3732import org .apache .cloudstack .context .CallContext ;
4136
4237import com .cloud .api .ApiDBUtils ;
4338import com .cloud .api .query .vo .ServiceOfferingJoinVO ;
39+ import com .cloud .dc .VsphereStoragePolicyVO ;
40+ import com .cloud .dc .dao .VsphereStoragePolicyDao ;
4441import com .cloud .offering .ServiceOffering ;
4542import com .cloud .server .ResourceTag .ResourceObjectType ;
43+ import com .cloud .storage .DiskOfferingVO ;
44+ import com .cloud .user .AccountManager ;
4645import com .cloud .utils .db .GenericDaoBase ;
46+ import com .cloud .utils .db .Filter ;
4747import com .cloud .utils .db .SearchBuilder ;
4848import com .cloud .utils .db .SearchCriteria ;
49+ import com .cloud .utils .db .TransactionLegacy ;
4950
5051import javax .inject .Inject ;
5152
53+ import static org .apache .cloudstack .query .QueryService .SortKeyAscending ;
54+
5255@ Component
5356public class ServiceOfferingJoinDaoImpl extends GenericDaoBase <ServiceOfferingJoinVO , Long > implements ServiceOfferingJoinDao {
5457 public static final Logger s_logger = Logger .getLogger (ServiceOfferingJoinDaoImpl .class );
@@ -230,6 +233,9 @@ public Map<Long, List<String>> listDomainsOfServiceOfferingsUsedByDomainPath(Str
230233
231234 @ Override
232235 public List <ServiceOfferingJoinVO > searchByIds (Long ... offeringIds ) {
236+ Filter searchFilter = new Filter (ServiceOfferingJoinVO .class , "sortKey" , SortKeyAscending .value ());
237+ searchFilter .addOrderBy (ServiceOfferingJoinVO .class , "id" , true );
238+
233239 // set detail batch query size
234240 int DETAILS_BATCH_SIZE = 2000 ;
235241 String batchCfg = configDao .getValue ("detail.batch.query.size" );
@@ -248,9 +254,9 @@ public List<ServiceOfferingJoinVO> searchByIds(Long... offeringIds) {
248254 }
249255 SearchCriteria <ServiceOfferingJoinVO > sc = srvOfferingSearch .create ();
250256 sc .setParameters ("idIN" , ids );
251- List <ServiceOfferingJoinVO > accounts = searchIncludingRemoved (sc , null , null , false );
252- if (accounts != null ) {
253- uvList .addAll (accounts );
257+ List <ServiceOfferingJoinVO > offerings = searchIncludingRemoved (sc , searchFilter , null , false );
258+ if (offerings != null ) {
259+ uvList .addAll (offerings );
254260 }
255261 curr_index += DETAILS_BATCH_SIZE ;
256262 }
@@ -264,9 +270,9 @@ public List<ServiceOfferingJoinVO> searchByIds(Long... offeringIds) {
264270 }
265271 SearchCriteria <ServiceOfferingJoinVO > sc = srvOfferingSearch .create ();
266272 sc .setParameters ("idIN" , ids );
267- List <ServiceOfferingJoinVO > accounts = searchIncludingRemoved (sc , null , null , false );
268- if (accounts != null ) {
269- uvList .addAll (accounts );
273+ List <ServiceOfferingJoinVO > offerings = searchIncludingRemoved (sc , searchFilter , null , false );
274+ if (offerings != null ) {
275+ uvList .addAll (offerings );
270276 }
271277 }
272278 return uvList ;
0 commit comments