當前位置: 首頁>>代碼示例>>Java>>正文


Java Database.endTransaction方法代碼示例

本文整理匯總了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();
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:DeleteQuery.java

示例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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:DbUtils.java

示例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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:AsyncOperationExecutor.java

示例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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:AsyncOperationExecutor.java


注:本文中的org.greenrobot.greendao.database.Database.endTransaction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。