Comments (5)
This is pretty wild. What database are you using? Are you always updating items?
from ormlite-android.
Hi, It's an Android app. a single assetDao via OrmLiteSqliteOpenHelper across the app.
createOrUpdate always returns success but no rows in the DB.. it's quite weird.
before update
1 a
2 b
3 c
4 d
5 f
...
after update
1 a'
2 b'
5 f'
...
// below code is run by around 10 threads at the same time.
// it parses data (tens of assets) and always update same table via the assetDao.
mAssetDao.callBatchTasks(new Callable() {
@OverRide
public Object call() throws Exception {
for (int i = 0; i < jsonAssets.length(); i++) {
JSONObject jsonAsset = jsonAssets.getJSONObject(i);
Asset asset = new Asset();
parseAsset(asset, jsonAsset);
mAssetDao.createOrUpdate(asset);
}
return null;
}
});
from ormlite-android.
Sorry for the delay. Can you write a junit test that reproduces this? We are getting ready to [finally] push 4.49 and I'd like to make sure this isn't an issue.
from ormlite-android.
Ok, I understand this now and it makes sense. Multiple threads cannot use the callBatchTasks(...)
at the same time because there is a single database connection and the transactions are getting screwed up. I just added the following to the javadocs:
NOTE: Depending on your underlying database implementation and whether or not you are working with a single database connection, you may need to synchronize around calls to this method otherwise the database transactions that are used may clash when called simultaneously from multiple threads. You may also need to synchronize other calls to transactions and dao.setAutoCommit(...)
.
from ormlite-android.
Related to #34
from ormlite-android.
Related Issues (20)
- android ,执行update操作,总是返回0 HOT 4
- ORMLite Android - Prevent Upgrade inside catch HOT 2
- The connection pool for database has been unable to grant a connection in ORMLite 5.1 HOT 5
- Missing or reset data HOT 3
- getReadWriteConnection: SQLiteCantOpenDatabaseException unknown error (Sqlite code 14): Could not open database, (OS error - 13:Permission denied)
- Is there any way we can get a 5.2 release to benefit from a bugfix in core 5.2? HOT 1
- Feature Request: SupportSQLiteOpenHelper HOT 2
- Null variable AndroidLogBackend causes "Could not construct instance of helper class" HOT 2
- UpdateBuilder use Nonparametric statement cause sql injection problem HOT 3
- Exception when create object with string including single quote HOT 2
- log4j HOT 2
- how to join two table? HOT 2
- [Bug] Using Limit and Offset causes SQL exception. HOT 3
- Duplicate classes and files when depending on a project using ormlite-core HOT 6
- Can't use a dependency with ormlite annotations. HOT 3
- Does ormlite support In-Memory database? HOT 1
- R8 minifyEnabled proguard rules
- EXTERNAL DATA IN SQL QUERIES [SAST] [M7] [CWE-89]
- Security vulnerability - SQL injection
- dao.queryForId() returns null even though row exists HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ormlite-android.