本文整理汇总了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();
}
}