当前位置: 首页>>代码示例>>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;未经允许,请勿转载。