本文整理了Java中com.j256.ormlite.dao.Dao.updateRaw()
方法的一些代码示例,展示了Dao.updateRaw()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.updateRaw()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:updateRaw
[英]Run a raw update SQL statement to the database. The statement must be an SQL INSERT, UPDATE or DELETE statement.The arguments are optional but can be set with strings to expand ? type of SQL.
[中]对数据库运行原始更新SQL语句。该语句必须是SQL INSERT、UPDATE或DELETE语句。参数是可选的,但可以使用字符串进行设置以展开?SQL的类型。
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#updateRaw(String, String...)
*/
@Override
public int updateRaw(String statement, String... arguments) {
try {
return dao.updateRaw(statement, arguments);
} catch (SQLException e) {
logMessage(e, "updateRaw threw exception on: " + statement);
throw new RuntimeException(e);
}
}
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#updateRaw(String, String...)
*/
@Override
public int updateRaw(String statement, String... arguments) {
try {
return dao.updateRaw(statement, arguments);
} catch (SQLException e) {
logMessage(e, "updateRaw threw exception on: " + statement);
throw new RuntimeException(e);
}
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = RuntimeException.class)
public void testUpdateRawThrow() throws Exception {
@SuppressWarnings("unchecked")
Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
expect(dao.updateRaw(null)).andThrow(new SQLException("Testing catch"));
replay(dao);
rtDao.updateRaw(null);
verify(dao);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testUnknownValueAnnotation() throws Exception {
Dao<LocalUnknownEnum, Object> dao = createDao(LocalUnknownEnum.class, true);
LocalUnknownEnum localUnknownEnum = new LocalUnknownEnum();
localUnknownEnum.ourEnum = OurEnum.SECOND;
assertEquals(1, dao.create(localUnknownEnum));
assertEquals(1, dao.updateRaw("UPDATE Foo set ourEnum = 'THIRD'"));
List<LocalUnknownEnum> unknowns = dao.queryForAll();
assertEquals(1, unknowns.size());
assertEquals(OurEnum.FIRST, unknowns.get(0).ourEnum);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testUpdateRaw() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo1 = new Foo();
assertEquals(1, dao.create(foo1));
Foo foo2 = new Foo();
assertEquals(1, dao.create(foo2));
assertEquals(2, dao.queryForAll().size());
dao.updateRaw("DELETE FROM FOO WHERE " + Foo.ID_COLUMN_NAME + " = ?", Integer.toString(foo1.id));
assertEquals(1, dao.queryForAll().size());
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testUnknownEnumValue() throws Exception {
Dao<LocalEnumString, Object> dao = createDao(LocalEnumString.class, true);
LocalEnumString localEnumString = new LocalEnumString();
localEnumString.ourEnum = OurEnum.FIRST;
assertEquals(1, dao.create(localEnumString));
assertEquals(1, dao.updateRaw("UPDATE Foo set ourEnum = 'THIRD'"));
dao.queryForAll();
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testUpdateRawThrow() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo = new Foo();
assertEquals(1, dao.create(foo));
DatabaseConnection conn = connectionSource.getReadWriteConnection(FOO_TABLE_NAME);
try {
conn.close();
dao.updateRaw("DELETE FROM FOO");
} finally {
connectionSource.releaseConnection(conn);
}
}
内容来源于网络,如有侵权,请联系作者删除!