use of org.greenrobot.greendao.database.DatabaseStatement in project greenDAO by greenrobot.
the class AbstractDao method deleteInTxInternal.
private void deleteInTxInternal(Iterable<T> entities, Iterable<K> keys) {
assertSinglePk();
DatabaseStatement stmt = statements.getDeleteStatement();
List<K> keysToRemoveFromIdentityScope = null;
db.beginTransaction();
try {
synchronized (stmt) {
if (identityScope != null) {
identityScope.lock();
keysToRemoveFromIdentityScope = new ArrayList<K>();
}
try {
if (entities != null) {
for (T entity : entities) {
K key = getKeyVerified(entity);
deleteByKeyInsideSynchronized(key, stmt);
if (keysToRemoveFromIdentityScope != null) {
keysToRemoveFromIdentityScope.add(key);
}
}
}
if (keys != null) {
for (K key : keys) {
deleteByKeyInsideSynchronized(key, stmt);
if (keysToRemoveFromIdentityScope != null) {
keysToRemoveFromIdentityScope.add(key);
}
}
}
} finally {
if (identityScope != null) {
identityScope.unlock();
}
}
}
db.setTransactionSuccessful();
if (keysToRemoveFromIdentityScope != null && identityScope != null) {
identityScope.remove(keysToRemoveFromIdentityScope);
}
} finally {
db.endTransaction();
}
}
Aggregations