本文整理了Java中com.j256.ormlite.dao.Dao.getWrappedIterable()
方法的一些代码示例,展示了Dao.getWrappedIterable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.getWrappedIterable()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:getWrappedIterable
[英]This makes a one time use iterable class that can be closed afterwards. The DAO itself is CloseableWrappedIterable but multiple threads can each call this to get their own closeable iterable. This allows you to do something like:
CloseableWrappedIterable<Foo> wrappedIterable = fooDao.getWrappedIterable();
try {
for (Foo foo : wrappedIterable) {
...
}
} finally {
wrappedIterable.close();
}
[中]这使得一个一次性使用的iterable类可以在以后关闭。DAO本身是CloseableWrappedTable,但是多个线程都可以调用它来获得自己的CloseableIterable。这允许您执行以下操作:
CloseableWrappedIterable<Foo> wrappedIterable = fooDao.getWrappedIterable();
try {
for (Foo foo : wrappedIterable) {
...
}
} finally {
wrappedIterable.close();
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#getWrappedIterable()
*/
@Override
public CloseableWrappedIterable<T> getWrappedIterable() {
return dao.getWrappedIterable();
}
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#getWrappedIterable()
*/
@Override
public CloseableWrappedIterable<T> getWrappedIterable() {
return dao.getWrappedIterable();
}
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#getWrappedIterable(PreparedQuery)
*/
@Override
public CloseableWrappedIterable<T> getWrappedIterable(PreparedQuery<T> preparedQuery) {
return dao.getWrappedIterable(preparedQuery);
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#getWrappedIterable(PreparedQuery)
*/
@Override
public CloseableWrappedIterable<T> getWrappedIterable(PreparedQuery<T> preparedQuery) {
return dao.getWrappedIterable(preparedQuery);
}
代码示例来源:origin: kamax-matrix/mxisd
@Override
public Collection<ThreePidInviteIO> getInvites() {
return forIterable(invDao.getWrappedIterable());
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testWrappedIterableFor() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo1 = new Foo();
assertEquals(1, dao.create(foo1));
CloseableWrappedIterable<Foo> wrapped = dao.getWrappedIterable();
try {
int fooC = 0;
for (Foo foo : wrapped) {
assertEquals(foo1.id, foo.id);
fooC++;
}
assertEquals(1, fooC);
} finally {
wrapped.close();
}
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testWrappedIterableForThrow() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo1 = new Foo();
assertEquals(1, dao.create(foo1));
CloseableWrappedIterable<Foo> wrapped = dao.getWrappedIterable();
dropTable(Foo.class, true);
try {
wrapped.iterator();
fail("Should have thrown");
} catch (IllegalStateException e) {
// expected
} finally {
wrapped.close();
}
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testWrappedIterator() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo1 = new Foo();
assertEquals(1, dao.create(foo1));
CloseableWrappedIterable<Foo> wrapped = dao.getWrappedIterable();
CloseableIterator<Foo> iterator = wrapped.closeableIterator();
// this shouldn't close anything
dao.closeLastIterator();
assertTrue(iterator.hasNext());
Foo foo3 = iterator.next();
assertEquals(foo1.id, foo3.id);
assertFalse(iterator.hasNext());
wrapped.close();
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testWrappedIterablePreparedQueryFor() 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));
CloseableWrappedIterable<Foo> wrapped =
dao.getWrappedIterable(dao.queryBuilder().where().eq(Foo.ID_COLUMN_NAME, foo1.id).prepare());
try {
int fooC = 0;
for (Foo foo : wrapped) {
assertEquals(foo1.id, foo.id);
fooC++;
}
assertEquals(1, fooC);
} finally {
wrapped.close();
}
}
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testWrappedIterableInvalidPreparedQueryFor() 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));
CloseableWrappedIterable<Foo> wrapped =
dao.getWrappedIterable(dao.queryBuilder().where().eq(Foo.ID_COLUMN_NAME, new SelectArg()).prepare());
try {
wrapped.iterator();
fail("Should have thrown");
} catch (IllegalStateException e) {
// expected
} finally {
wrapped.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!