本文整理匯總了Java中org.greenrobot.greendao.database.Database.endTransaction方法的典型用法代碼示例。如果您正苦於以下問題:Java Database.endTransaction方法的具體用法?Java Database.endTransaction怎麽用?Java Database.endTransaction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.greenrobot.greendao.database.Database
的用法示例。
在下文中一共展示了Database.endTransaction方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeDeleteWithoutDetachingEntities
import org.greenrobot.greendao.database.Database; //導入方法依賴的package包/類
/**
* Deletes all matching entities without detaching them from the identity scope (aka session/cache). Note that this
* method may lead to stale entity objects in the session cache. Stale entities may be returned when loaded by
* their
* primary key, but not using queries.
*/
public void executeDeleteWithoutDetachingEntities() {
checkThread();
Database db = dao.getDatabase();
if (db.isDbLockedByCurrentThread()) {
dao.getDatabase().execSQL(sql, parameters);
} else {
// Do TX to acquire a connection before locking this to avoid deadlocks
// Locking order as described in AbstractDao
db.beginTransaction();
try {
dao.getDatabase().execSQL(sql, parameters);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
}
示例2: executeSqlStatementsInTx
import org.greenrobot.greendao.database.Database; //導入方法依賴的package包/類
public static int executeSqlStatementsInTx(Database db, String[] statements) {
db.beginTransaction();
try {
int count = executeSqlStatements(db, statements);
db.setTransactionSuccessful();
return count;
} finally {
db.endTransaction();
}
}
示例3: executeTransactionRunnable
import org.greenrobot.greendao.database.Database; //導入方法依賴的package包/類
private void executeTransactionRunnable(AsyncOperation operation) {
Database db = operation.getDatabase();
db.beginTransaction();
try {
((Runnable) operation.parameter).run();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
示例4: executeTransactionCallable
import org.greenrobot.greendao.database.Database; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void executeTransactionCallable(AsyncOperation operation) throws Exception {
Database db = operation.getDatabase();
db.beginTransaction();
try {
operation.result = ((Callable<Object>) operation.parameter).call();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}