gpt4 book ai didi

java - OrmLite:Dao.callBatchTasks() 和 TransactionManager.callInTransaction() 之间的区别

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:28:31 26 4
gpt4 key购买 nike

这些方法有什么区别?我已经阅读了文档,但我不明白 callBatchTasks 方法的作用。文档说:

This will turn off what databases call "auto-commit" mode, run the call-able and then re-enable "auto-commit".

这不是交易吗?

谢谢。

最佳答案

Difference between Dao.callBatchTasks() and TransactionManager.callInTransaction()

差异取决于您使用的数据库。在安卓下,没有区别。 callBatchTasks(...) 的 javadoc 说:

Call the call-able that will perform a number of batch tasks. This is for performance when you want to run a number of database operations at once -- maybe loading data from a file. This will turn off what databases call "auto-commit" mode, run the call-able, and then re-enable "auto-commit". If auto-commit is not supported then a transaction will be used instead.

Android 的 SQLite 是数据库之一。在内部 ORMLite 代码中,您会看到:

private <CT> CT doCallBatchTasks(DatabaseConnection connection, boolean saved,
Callable<CT> callable) throws SQLException {
if (databaseType.isBatchUseTransaction()) {
return TransactionManager.callInTransaction(connection, saved, databaseType,
callable);
}
...

所以在内部,当在 Android 下使用时,dao.callBatchTasks(...) 是对 TransactionManager.callInTransaction(...) 的调用。

关于java - OrmLite:Dao.callBatchTasks() 和 TransactionManager.callInTransaction() 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28627490/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com