addition of locking in Dao.callBatchTasks(...) if using a single database connection

41 views
Skip to first unread message

Gray Watson

unread,
Feb 17, 2015, 11:43:25 AM2/17/15
to ORMLite Users, ORMLite Developers, ORMLite Android
I've been doing some investigation of the following Android issues:

https://github.com/j256/ormlite-android/issues/16
https://github.com/j256/ormlite-android/issues/34

After looking at the code I now understand that when multiple threads are working with a connection-source that serves one database connection (like Android), concurrent calls to dao.callBatchTasks(...) could cause data issues because of race-conditions around the transactions being opened/committed.

I've added a lot of javadocs to dao.setAutoCommit(...) and the TransactionManager if folks are using those classes on their own. However, I felt that ORMLite should force the locking in callBatchTasks(). So in 4.49 I've added code to make an attempt at detecting if the connection-source is backed with a single-connection (such as Android). When it is a single connection, it will synchronize on an internal object to stop concurrent usage of callBatchTasks(...).

Comments?
gray

Reply all
Reply to author
Forward
0 new messages