OrmLite:Dao.callBatchTasks() 和 TransactionManager.callInTransaction() 之间的区别
OrmLite: Difference between Dao.callBatchTasks() and TransactionManager.callInTransaction()
这些方法有什么区别?我已经阅读了文档,但我不明白 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()
差异取决于您使用的数据库。 Android下没有区别。 callBatchTasks(...)
的 javadocs 说:
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(...)
的调用。
这些方法有什么区别?我已经阅读了文档,但我不明白 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()
andTransactionManager.callInTransaction()
差异取决于您使用的数据库。 Android下没有区别。 callBatchTasks(...)
的 javadocs 说:
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(...)
的调用。