I have a problem understanding the default behavior of the DaoManager.
DaoManager.createDao(connectionSource, theClass);
This takes a connectionSource - not a connection. So if I do the following:
TransactionManager.callInTransaction(
localConnection,
connectionSource.getDatabaseType(),
new Callable<Void>() {
public Void call() throws Exception {
dao.create(user);
dao.create(player);
return null;
}
});
The transaction should be limited to a single connection (the localConnection). How does the DAO handle that? Or does it not handle it at all?
The transaction should be limited to a single connection (the localConnection). How does the DAO handle that? Or does it not handle it at all?
Hrm. I'm not 100% sure why the connection method is exposed. I'm going to deprecate it.
You really should be using the dao.callBatchTasks(...) method. If you need to use the TransactionManager directly, I'd use the method that takes a ConnectionSource, not a connection.
You can take a look at the source of TransactionManager.callInTransaction(...) to see that it is saving the connection which then is used by the DAO later through some ORMLite magic. So auto-commit is disabled on the saved connection and then restored after the batch tasks complete.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With