本文整理了Java中com.j256.ormlite.dao.Dao.deleteById()
方法的一些代码示例,展示了Dao.deleteById()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.deleteById()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:deleteById
[英]Delete an object from the database that has an id.
[中]从数据库中删除具有id的对象。
代码示例来源:origin: BaronZ88/MinimalistWeather
public void deleteById(String cityId) throws SQLException {
weatherDaoOperation.deleteById(cityId);
}
代码示例来源:origin: lamarios/Homedash2
@Override
public boolean deleteById(String id) throws SQLException {
return DB.SETTINGS_DAO.deleteById(id) == 1;
}
代码示例来源:origin: lamarios/Homedash2
@Override
public boolean deleteById(Integer id) throws Exception {
return REMOTE_FAVORITE_DAO.deleteById(id) == 1;
}
代码示例来源:origin: lamarios/Homedash2
@Override
public boolean deleteById(Integer id) throws SQLException {
return DB.MODULE_LAYOUT_DAO.deleteById(id) == 1;
}
代码示例来源:origin: lamarios/Homedash2
@Override
public boolean deleteById(Integer id) throws SQLException {
return DB.MODULE_SETTINGS_DAO.deleteById(id) == 1;
}
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#deleteById(Object)
*/
@Override
public int deleteById(ID id) {
try {
return dao.deleteById(id);
} catch (SQLException e) {
logMessage(e, "deleteById threw exception on: " + id);
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#deleteById(Object)
*/
@Override
public int deleteById(ID id) {
try {
return dao.deleteById(id);
} catch (SQLException e) {
logMessage(e, "deleteById threw exception on: " + id);
throw new RuntimeException(e);
}
}
代码示例来源:origin: kamax-matrix/mxisd
@Override
public void deleteInvite(String id) {
withCatcher(() -> {
int updated = invDao.deleteById(id);
if (updated != 1) {
throw new RuntimeException("Unexpected row count after DB action: " + updated);
}
});
}
代码示例来源:origin: org.mycontroller.standalone/mycontroller-core
public void deleteById(Tid id) {
try {
this.getDao().deleteById(id);
} catch (SQLException ex) {
_logger.error("unable to delete item, id:[{}]", id, ex);
}
}
代码示例来源:origin: com.octo.android.robospice/robospice-ormlite
public <T, ID> void deleteByIdFromDataBase(ID id, Class<T> modelObjectClass) throws SQLException {
Dao<T, ID> dao = getDao(modelObjectClass);
dao.deleteById(id);
}
代码示例来源:origin: mycontroller-org/mycontroller
public void deleteById(Tid id) {
try {
this.getDao().deleteById(id);
} catch (SQLException ex) {
_logger.error("unable to delete item, id:[{}]", id, ex);
throw new McDatabaseException(ex);
}
}
代码示例来源:origin: QuickBlox/q-municate-android
@Override
public void deleteById(ID id) {
try {
dao.deleteById(id);
notifyObservers(OBSERVE_KEY);
} catch (SQLException e) {
ErrorUtils.logError(e);
}
}
代码示例来源:origin: QuickBlox/q-municate-android
@Override
public void deleteById(long id) {
try {
dao.deleteById(id);
notifyObserversDeletedById(id);
} catch (SQLException e) {
ErrorUtils.logError(e);
}
}
代码示例来源:origin: ikidou/Retrofit2Demo
@Override
public Object handle(Request request, Response response) throws Exception {
long id = getId(request);
if (id >= 0) {
getDao().deleteById(id);
return Resp.create(200, "OK");
}
return Resp.create(400, "Miss `id` attribute");
}
},
代码示例来源:origin: org.mycontroller.standalone/mycontroller-core
private void delete(Integer id, String name) {
try {
int count = 0;
if (id != null) {
count = this.getDao().deleteById(id);
} else if (name != null) {
DeleteBuilder<ResourcesGroup, Integer> deleteBuilder = this.getDao().deleteBuilder();
deleteBuilder.where().eq("name", name);
count = deleteBuilder.delete();
}
_logger.debug("ResourcesGroup:[id:{}, name:{}] deleted, Delete count:{}", id, name, count);
} catch (SQLException ex) {
_logger.error("unable to delete resourcesGroup:[id:{}, name:{}]", id, name, ex);
}
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = RuntimeException.class)
public void testDeleteByIdThrow() 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.deleteById(null)).andThrow(new SQLException("Testing catch"));
replay(dao);
rtDao.deleteById(null);
verify(dao);
}
代码示例来源:origin: mycontroller-org/mycontroller
private void delete(Integer id, String name) {
try {
int count = 0;
if (id != null) {
count = this.getDao().deleteById(id);
} else if (name != null) {
DeleteBuilder<ResourcesGroup, Integer> deleteBuilder = this.getDao().deleteBuilder();
deleteBuilder.where().eq("name", name);
count = deleteBuilder.delete();
}
_logger.debug("ResourcesGroup:[id:{}, name:{}] deleted, Delete count:{}", id, name, count);
} catch (SQLException ex) {
_logger.error("unable to delete resourcesGroup:[id:{}, name:{}]", id, name, ex);
throw new McDatabaseException(ex);
}
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testDeleteByIdNull() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.deleteById(null));
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testDeleteById() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo = new Foo();
assertEquals(1, dao.create(foo));
assertNotNull(dao.queryForId(foo.id));
assertEquals(1, dao.deleteById(foo.id));
assertNull(dao.queryForId(foo.id));
assertEquals(0, dao.queryForAll().size());
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testDeleteByIdThrow() 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.deleteById(foo.id);
} finally {
connectionSource.releaseConnection(conn);
}
}
内容来源于网络,如有侵权,请联系作者删除!