EntitlementCurator extends AbstractHibernateCurator<Entitlement> { public int batchDeleteByIds(Collection<String> entitlementIds) { int deleted = 0; if (entitlementIds != null) { String jpql = "DELETE FROM Entitlement e WHERE e.id IN (:eids)"; Query query = this.getEntityManager().createQuery(jpql); int blockSize = Math.min(this.getInBlockSize(), this.getQueryParameterLimit()); for (List<String> block : Iterables.partition(entitlementIds, blockSize)) { deleted += query.setParameter("eids", block) .executeUpdate(); } } return deleted; } @Inject  EntitlementCurator(OwnerProductCurator ownerProductCurator, ProductCurator productCurator,
        ConsumerTypeCurator consumerTypeCurator, CandlepinQueryFactory cpQueryFactory); @Transactional Set<Entitlement> bulkUpdate(Set<Entitlement> entitlements); List<Entitlement> listByConsumer(Consumer consumer); List<Entitlement> listByConsumer(Consumer consumer, EntitlementFilterBuilder filters); List<Entitlement> listByConsumerAndPoolId(Consumer consumer, String poolId); Page<List<Entitlement>> listByConsumer(Consumer consumer, String productId,
        EntitlementFilterBuilder filters, PageRequest pageRequest); Page<List<Entitlement>> listByOwner(Owner owner, String productId,
        EntitlementFilterBuilder filters, PageRequest pageRequest); Page<List<Entitlement>> listAll(EntitlementFilterBuilder filters, PageRequest pageRequest); CandlepinQuery<Entitlement> listByOwner(Owner owner); CandlepinQuery<Entitlement> listByEnvironment(Environment environment); CandlepinQuery<Entitlement> listByEnvironment(String environmentId); CandlepinQuery<Entitlement> listByConsumerAndDate(Consumer consumer, Date activeOn); List<Entitlement> listDirty(Consumer consumer); Set<String> listEntitledProductIds(Consumer consumer, Pool pool); int markDependentEntitlementsDirty(Iterable<String> entitlementIds); Set<String> filterDistributorEntitlementIds(Iterable<String> entsIdsToFilter); @Transactional int markEntitlementsDirty(Iterable<String> entitlementIds); @Deprecated Map<Consumer, List<Entitlement>> getDistinctConsumers(List<Entitlement> entsToRevoke); @Transactional void delete(Entitlement entity); void batchDelete(Collection<Entitlement> entitlements); int batchDeleteByIds(Collection<String> entitlementIds); void unlinkEntitlements(Collection<Entitlement> entitlements); @Transactional Entitlement findByCertificateSerial(Long serial); @Transactional Entitlement replicate(Entitlement ent); @SuppressWarnings("unchecked") CandlepinQuery<Entitlement> findByStackId(Consumer consumer, String stackId); @SuppressWarnings("unchecked") CandlepinQuery<Entitlement> findByStackIds(Consumer consumer, Collection stackIds); @SuppressWarnings("unchecked") CandlepinQuery<Entitlement> findByPoolAttribute(Consumer consumer, String attributeName,
        String value); CandlepinQuery<Entitlement> findByPoolAttribute(String attributeName, String value); Entitlement findUpstreamEntitlementForStack(Consumer consumer, String stackId); Collection<String> getDependentEntitlementIdsForPools(Consumer consumer,
        Iterable<String> poolIds);  }
@Test public void testBatchDeleteEntitlementsWithLargeDataSet() { int defaultLimit = 32000; int configLimit = this.entitlementCurator.getQueryParameterLimit(); int testLimit = Math.max(defaultLimit, configLimit) * 2; int entitlementCount = 10; Owner owner = this.createOwner(); Consumer consumer = this.createConsumer(owner); Product product = this.createProduct(owner); Pool pool = this.createPool(owner, product); List<String> entIds = new LinkedList<>(); for (int i = 0; i < testLimit; ++i) { entIds.add("test_id-" + i); } for (int i = 0; i < entitlementCount; ++i) { Entitlement entitlement = this.createEntitlement(owner, consumer, pool); entIds.add(entitlement.getId()); } int deleted = this.entitlementCurator.batchDeleteByIds(entIds); assertEquals(entitlementCount, deleted); }