I was wondering if ormLite locked the database when it executed a transaction. I have table:
key | value
AA | 1
BB | 1
I have two database operations running. One modifies multiple entries:
new Callable<Void>() {
public Void call() throws SQLException {
pairAA = new DbEntry("AA", 2);
pairBB = new DbEntry("BB", 2);
dao.createOrUpdate(pairAA);
dao.createOrUpdate(pairBB);
return null;
}
}
If I try to run the first on different thread, using TransactionManager.callInTransaction()
is it possible to get 3 as a result of sumAllValues(dao.queryAll())
? Running on different threads means the JVM may try to execute queryAll()
between createOrUpdate(pairAA)
and createOrUpdate(pairBB)
. Which would mean AA becomes 2, BB is still 1 when the query reads it. Or would the transaction manager lock that table/database for the whole execution of the callable, making it impossible for the query to happen (only allowing it before or after the callable)?