Spring JpaRepostory 删除与 deleteInBatch [英] Spring JpaRepostory delete vs deleteInBatch

查看:23
本文介绍了Spring JpaRepostory 删除与 deleteInBatch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring JpaRepostory 中的 delete(...)deleteInBatch(...) 方法有什么区别?第二个删除一个 SQL 语句中的项目",但从应用程序/数据库的角度来看,这意味着什么?为什么存在两种结果相似的不同方法,何时使用一种或另一种更好?

What is the difference between delete(...) and deleteInBatch(...) methods in JpaRepostory in Spring ? The second one "deletes items in one SQL statement", but what does it mean from the application/database perspective ? Why exists two different methods with the similar results and when it is better to use one or other ?

这同样适用于 deleteAll()deleteAllInBatch() ...

The same applies also for deleteAll() and deleteAllInBatch() ...

推荐答案

delete 方法将在一次操作中删除您的实体.deleteInBatch 将批处理多个删除语句并将它们作为 1 个操作删除.

The delete method is going to delete your entity in one operation. The deleteInBatch is going to batch several delete-statements and delete them as 1 operation.

如果您需要大量删除操作,批量删除可能会更快.

If you need a lot of delete operations the batch-deletion might be faster.

这篇关于Spring JpaRepostory 删除与 deleteInBatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆