本文整理了Java中com.j256.ormlite.dao.Dao.commit()
方法的一些代码示例,展示了Dao.commit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.commit()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:commit
[英]If you have previously set auto-commit to false using #setAutoCommit(DatabaseConnection,boolean) then this will commit all changes to the database made from that point up to now on the connection returned by the #startThreadConnection(). The changes will be written to the database and discarded. The connection will continue to stay in the current auto-commit mode.
WARNING: Chances are you should be using the #callBatchTasks(Callable) instead of this method unless you know what you are doing.
NOTE: Depending on your underlying database implementation and whether or not you are working with a single database connection, you may need to synchronize calls to here and calls to #callBatchTasks(Callable), #setAutoCommit(DatabaseConnection,boolean), and #rollBack(DatabaseConnection).
[中]如果以前使用#setAutoCommit(DatabaseConnection,boolean)将auto commit设置为false,则这将提交从该点到现在为止对#startThreadConnection()返回的连接所做的所有数据库更改。更改将写入数据库并被丢弃。连接将继续保持当前自动提交模式。
警告:除非您知道自己在做什么,否则您可能应该使用#callBatchTasks(Callable)而不是此方法。
注意:根据基础数据库实现以及是否使用单个数据库连接,您可能需要同步对此处的调用以及对#callBatchTasks(可调用)、setAutoCommit(DatabaseConnection,布尔值)和#rollBack(DatabaseConnection)的调用。
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#commit(DatabaseConnection)
*/
@Override
public void commit(DatabaseConnection connection) {
try {
dao.commit(connection);
} catch (SQLException e) {
logMessage(e, "commit(" + connection + ") threw exception");
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#commit(DatabaseConnection)
*/
@Override
public void commit(DatabaseConnection connection) {
try {
dao.commit(connection);
} catch (SQLException e) {
logMessage(e, "commit(" + connection + ") threw exception");
throw new RuntimeException(e);
}
}
代码示例来源:origin: ikidou/Retrofit2Demo
blogDao.commit(databaseConnection);
databaseConnection.setAutoCommit(autoCommit);
代码示例来源:origin: j256/ormlite-core
@Test
public void testConnectionMethods() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
DatabaseConnection conn = null;
try {
conn = dao.startThreadConnection();
assertTrue(dao.isAutoCommit(conn));
dao.setAutoCommit(conn, false);
assertFalse(dao.isAutoCommit(conn));
Foo foo = new Foo();
assertEquals(1, dao.create(foo));
assertNotNull(dao.queryForId(foo.id));
dao.rollBack(conn);
assertNull(dao.queryForId(foo.id));
foo = new Foo();
assertEquals(1, dao.create(foo));
assertNotNull(dao.queryForId(foo.id));
dao.commit(conn);
assertNotNull(dao.queryForId(foo.id));
dao.rollBack(conn);
assertNotNull(dao.queryForId(foo.id));
} finally {
if (conn != null) {
conn.setAutoCommit(true);
dao.endThreadConnection(conn);
}
}
}
代码示例来源:origin: com.j256.ormlite/ormlite-jdbc
assertNotNull(dao.queryForId(foo.id));
dao.commit(conn);
assertNotNull(dao.queryForId(foo.id));
内容来源于网络,如有侵权,请联系作者删除!