com.j256.ormlite.dao.Dao.deleteIds()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中com.j256.ormlite.dao.Dao.deleteIds()方法的一些代码示例,展示了Dao.deleteIds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.deleteIds()方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:deleteIds

Dao.deleteIds介绍

[英]Delete the objects that match the collection of ids from the database using an IN SQL clause.
[中]使用IN SQL子句从数据库中删除与ID集合匹配的对象。

代码示例

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

  1. public void deleteByIds(List<Tid> ids) {
  2. try {
  3. Integer count = this.getDao().deleteIds(ids);
  4. _logger.debug("Ids:[{}] deleted, Delete count:{}", ids, count);
  5. } catch (SQLException ex) {
  6. _logger.error("unable to delete Ids:[{}]", ids, ex);
  7. }
  8. }

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

  1. @Override
  2. public void delete(List<Integer> ids) {
  3. try {
  4. int count = this.getDao().deleteIds(ids);
  5. _logger.debug("Ids:[{}] deleted, Delete count:{}", ids, count);
  6. } catch (SQLException ex) {
  7. _logger.error("unable to delete logs:[{}]", ids, ex);
  8. }
  9. }
  10. }

代码示例来源:origin: j256/ormlite-core

  1. /**
  2. * @see Dao#deleteIds(Collection)
  3. */
  4. @Override
  5. public int deleteIds(Collection<ID> ids) {
  6. try {
  7. return dao.deleteIds(ids);
  8. } catch (SQLException e) {
  9. logMessage(e, "deleteIds threw exception on: " + ids);
  10. throw new RuntimeException(e);
  11. }
  12. }

代码示例来源:origin: com.j256.ormlite/ormlite-core

  1. /**
  2. * @see Dao#deleteIds(Collection)
  3. */
  4. @Override
  5. public int deleteIds(Collection<ID> ids) {
  6. try {
  7. return dao.deleteIds(ids);
  8. } catch (SQLException e) {
  9. logMessage(e, "deleteIds threw exception on: " + ids);
  10. throw new RuntimeException(e);
  11. }
  12. }

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

  1. @Override
  2. public void delete(List<Integer> ids) {
  3. try {
  4. int deleteCount = this.getDao().deleteIds(ids);
  5. _logger.debug("Deleted [ids:{}], delete count:{}", ids, deleteCount);
  6. } catch (SQLException ex) {
  7. _logger.debug("unable to deleted [ids:{}]", ids, ex);
  8. }
  9. }

代码示例来源:origin: mycontroller-org/mycontroller

  1. @Override
  2. public void delete(List<Integer> ids) {
  3. try {
  4. int deleteCount = this.getDao().deleteIds(ids);
  5. _logger.debug("Deleted [ids:{}], delete count:{}", ids, deleteCount);
  6. } catch (SQLException ex) {
  7. _logger.debug("unable to deleted [ids:{}]", ids, ex);
  8. throw new McDatabaseException(ex);
  9. }
  10. }

代码示例来源:origin: mycontroller-org/mycontroller

  1. public void deleteByIds(List<Tid> ids) {
  2. try {
  3. Integer count = this.getDao().deleteIds(ids);
  4. _logger.debug("Ids:[{}] deleted, Delete count:{}", ids, count);
  5. } catch (SQLException ex) {
  6. _logger.error("unable to delete Ids:[{}]", ids, ex);
  7. throw new McDatabaseException(ex);
  8. }
  9. }

代码示例来源:origin: mycontroller-org/mycontroller

  1. @Override
  2. public void delete(List<Integer> ids) {
  3. try {
  4. int count = this.getDao().deleteIds(ids);
  5. _logger.debug("Ids:[{}] deleted, Delete count:{}", ids, count);
  6. } catch (SQLException ex) {
  7. _logger.error("unable to delete logs:[{}]", ids, ex);
  8. throw new McDatabaseException(ex);
  9. }
  10. }
  11. }

代码示例来源:origin: jclehner/rxdroid

  1. public static <E extends Entry> void deleteByIds(Class<? extends Entry> clazz, Collection<Integer> ids)
  2. {
  3. final Dao<? extends Entry, Integer> dao = getDaoChecked(clazz);
  4. try
  5. {
  6. dao.deleteIds(ids);
  7. }
  8. catch(SQLException e)
  9. {
  10. throw new WrappedCheckedException(e);
  11. }
  12. }

代码示例来源:origin: j256/ormlite-core

  1. @Test(expected = RuntimeException.class)
  2. public void testDeleteIdsThrow() throws Exception {
  3. @SuppressWarnings("unchecked")
  4. Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
  5. RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
  6. expect(dao.deleteIds(null)).andThrow(new SQLException("Testing catch"));
  7. replay(dao);
  8. rtDao.deleteIds(null);
  9. verify(dao);
  10. }

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

  1. @Test
  2. public void testDeleteIdsNone() throws Exception {
  3. Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
  4. List<Integer> fooIdList = new ArrayList<Integer>();
  5. assertEquals(fooIdList.size(), fooDao.deleteIds(fooIdList));
  6. assertEquals(0, fooDao.queryForAll().size());
  7. }

代码示例来源:origin: j256/ormlite-core

  1. @Test(expected = SQLException.class)
  2. public void testDeleteIdsNoId() throws Exception {
  3. Dao<NoId, Object> noIdDao = createDao(NoId.class, true);
  4. NoId noId = new NoId();
  5. noId.stuff = "1";
  6. assertEquals(1, noIdDao.create(noId));
  7. ArrayList<Object> noIdList = new ArrayList<Object>();
  8. noIdList.add(noId);
  9. noIdDao.deleteIds(noIdList);
  10. }

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

  1. @Test
  2. public void testDeleteIds() throws Exception {
  3. final Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
  4. final List<Integer> fooIdList = new ArrayList<Integer>();
  5. fooDao.callBatchTasks(new Callable<Void>() {
  6. @Override
  7. public Void call() throws Exception {
  8. for (int i = 0; i < 100; i++) {
  9. Foo foo = new Foo();
  10. assertEquals(1, fooDao.create(foo));
  11. fooIdList.add(foo.id);
  12. }
  13. return null;
  14. }
  15. });
  16. assertEquals(fooIdList.size(), fooDao.deleteIds(fooIdList));
  17. assertEquals(0, fooDao.queryForAll().size());
  18. }

代码示例来源:origin: j256/ormlite-core

  1. @Test(expected = SQLException.class)
  2. public void testDeleteIdsThrow() throws Exception {
  3. Dao<Foo, Integer> dao = createDao(Foo.class, true);
  4. Foo foo = new Foo();
  5. assertEquals(1, dao.create(foo));
  6. DatabaseConnection conn = connectionSource.getReadWriteConnection(FOO_TABLE_NAME);
  7. try {
  8. conn.close();
  9. List<Integer> foos = new ArrayList<Integer>();
  10. foos.add(foo.id);
  11. dao.deleteIds(foos);
  12. } finally {
  13. connectionSource.releaseConnection(conn);
  14. }
  15. }

代码示例来源:origin: j256/ormlite-core

  1. @Test
  2. public void testDeleteIds() throws Exception {
  3. Dao<Foo, Integer> dao = createDao(Foo.class, true);
  4. Foo foo1 = new Foo();
  5. assertEquals(1, dao.create(foo1));
  6. Foo foo2 = new Foo();
  7. assertEquals(1, dao.create(foo2));
  8. assertNotNull(dao.queryForId(foo1.id));
  9. assertNotNull(dao.queryForId(foo2.id));
  10. List<Integer> ids = new ArrayList<Integer>();
  11. ids.add(foo1.id);
  12. ids.add(foo2.id);
  13. assertEquals(2, dao.deleteIds(ids));
  14. assertEquals(0, dao.queryForAll().size());
  15. assertNull(dao.queryForId(foo1.id));
  16. assertNull(dao.queryForId(foo2.id));
  17. }

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

  1. idList.add(id1);
  2. idList.add(id2);
  3. assertEquals(2, dao.deleteIds(idList));
  4. assertNull(dao.queryForId(id1));
  5. assertNull(dao.queryForId(id2));

相关文章