SqlUpdate sqlDelete = intRow.createDelete(server, DeleteMode.HARD); persister.executeSqlUpdate(sqlDelete, transaction);
/** * Delete the 'many' detail beans for a given parent bean. * <p> * For stateless updates this deletes details beans that are no longer in * the many - the excludeDetailIds holds the detail beans that are in the * collection (and should not be deleted). * </p> */ void deleteManyDetails(SpiTransaction t, BeanDescriptor<?> desc, EntityBean parentBean, BeanPropertyAssocMany<?> many, List<Object> excludeDetailIds, DeleteMode deleteMode) { if (many.getCascadeInfo().isDelete()) { // cascade delete the beans in the collection BeanDescriptor<?> targetDesc = many.getTargetDescriptor(); if (deleteMode.isHard() || targetDesc.isSoftDelete()) { if (targetDesc.isDeleteByStatement()) { // Just delete all the children with one statement IntersectionRow intRow = many.buildManyDeleteChildren(parentBean, excludeDetailIds); SqlUpdate sqlDelete = intRow.createDelete(server, deleteMode); executeSqlUpdate(sqlDelete, t); } else { // Delete recurse using the Id values of the children Object parentId = desc.getId(parentBean); List<Object> idsByParentId = many.findIdsByParentId(parentId, null, t, excludeDetailIds, deleteMode.isHard()); if (!idsByParentId.isEmpty()) { deleteChildrenById(t, targetDesc, idsByParentId, deleteMode); } } } } }
SpiSqlUpdate sqlDelete = intRow.createDelete(server, DeleteMode.HARD); persister.executeOrQueue(sqlDelete, transaction, queue);
/** * Delete the 'many' detail beans for a given parent bean. * <p> * For stateless updates this deletes details beans that are no longer in * the many - the excludeDetailIds holds the detail beans that are in the * collection (and should not be deleted). * </p> */ void deleteManyDetails(SpiTransaction t, BeanDescriptor<?> desc, EntityBean parentBean, BeanPropertyAssocMany<?> many, List<Object> excludeDetailIds, DeleteMode deleteMode) { if (many.getCascadeInfo().isDelete()) { // cascade delete the beans in the collection BeanDescriptor<?> targetDesc = many.getTargetDescriptor(); if (deleteMode.isHard() || targetDesc.isSoftDelete()) { if (targetDesc.isDeleteByStatement()) { // Just delete all the children with one statement IntersectionRow intRow = many.buildManyDeleteChildren(parentBean, excludeDetailIds); SqlUpdate sqlDelete = intRow.createDelete(server, deleteMode); executeSqlUpdate(sqlDelete, t); } else { // Delete recurse using the Id values of the children Object parentId = desc.getId(parentBean); List<Object> idsByParentId = many.findIdsByParentId(parentId, null, t, excludeDetailIds, deleteMode.isHard()); if (!idsByParentId.isEmpty()) { deleteChildrenById(t, targetDesc, idsByParentId, deleteMode); } } } } }