Class DeleteServiceImpl
java.lang.Object
ch.tocco.nice2.persist.entity.impl.delete.DeleteServiceImpl
- All Implemented Interfaces:
DeleteService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplementation of theDeleteService.EntityDatainterface, which is part of the result structure.static classNested classes/interfaces inherited from interface DeleteService
DeleteService.DeleteWatcher, DeleteService.EntityData, DeleteService.EntityDeletionData -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intWe can't delete too many entities at once, because the deletion is executed in a single transaction which would consume too much heap space if it contained too many entities. -
Constructor Summary
ConstructorsConstructorDescriptionDeleteServiceImpl(Context context, PersistenceService persistenceService, SecurityManager securityManager, BusinessUnitManager businessUnitManager) -
Method Summary
Modifier and TypeMethodDescriptioncreateDeletionData(EntityModel model, List<PrimaryKey> keys) Returns a report that contains information whether the given entities may be deleted using a cascading delete.deleteEntities(EntityModel model, List<PrimaryKey> keys, DeleteService.DeleteWatcher watcher) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DeleteService
deleteEntities, deleteEntity, getPartitionedTask
-
Field Details
-
DELETE_LIMIT
@VisibleForTesting public static final int DELETE_LIMITWe can't delete too many entities at once, because the deletion is executed in a single transaction which would consume too much heap space if it contained too many entities. It is difficult to predict how many entities we could delete in a single request, because in this limit isn't represented whatever some listeners might do when triggered and, thus, it isn't the same for all entity models. This limit of 10k is derived by deleting `Membership` entities and measuring memory usage for it -> A total of 10k entities (including related entities, not only Membership entities) already takes up about 300M of the heap space. We shouldn't go higher than that (e.g. a limit of 20k in this constellation already leads to OOM and a crash for a Nice instance with a total memory of 1G).- See Also:
-
-
Constructor Details
-
DeleteServiceImpl
public DeleteServiceImpl(Context context, PersistenceService persistenceService, SecurityManager securityManager, BusinessUnitManager businessUnitManager)
-
-
Method Details
-
createDeletionData
public Map<EntityId, DeleteService.EntityDeletionData> createDeletionData(EntityModel model, List<PrimaryKey> keys) Description copied from interface:DeleteServiceReturns a report that contains information whether the given entities may be deleted using a cascading delete. The report also contains all entities that would be additionally deleted and all entities that would block the cascading delete.- Specified by:
createDeletionDatain interfaceDeleteService- Parameters:
model- the entity modelkeys- keys of all entities that should be deleted.
-
deleteEntities
public List<EntityId> deleteEntities(EntityModel model, List<PrimaryKey> keys, DeleteService.DeleteWatcher watcher) throws DeleteException - Specified by:
deleteEntitiesin interfaceDeleteService- Throws:
DeleteException
-