本文整理了Java中org.greenrobot.greendao.query.Query.listLazyUncached
方法的一些代码示例,展示了Query.listLazyUncached
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.listLazyUncached
方法的具体详情如下:
包路径:org.greenrobot.greendao.query.Query
类名称:Query
方法名:listLazyUncached
[英]Executes the query and returns the result as a list that lazy loads the entities on every access (uncached). Make sure to close the list to close the underlying cursor.
[中]执行查询并将结果作为列表返回,该列表在每次访问(未缓存)时延迟加载实体。确保关闭列表以关闭基础光标。
代码示例来源:origin: greenrobot/greenDAO
/**
* Executes the query and returns the result as a list iterator; make sure to close it to close the underlying
* cursor. The cursor is closed once the iterator is fully iterated through.
*/
public CloseableListIterator<T> listIterator() {
return listLazyUncached().listIteratorAutoClose();
}
代码示例来源:origin: greenrobot/greenDAO
/**
* Shorthand for {@link QueryBuilder#build() build()}.{@link Query#listLazyUncached() listLazyUncached()}; see
* {@link Query#listLazyUncached()} for details. To execute a query more than once, you should build the query and
* keep the {@link Query} object for efficiency reasons.
*/
public LazyList<T> listLazyUncached() {
return build().listLazyUncached();
}
代码示例来源:origin: greenrobot/greenDAO
@Override
public void call(Subscriber<? super T> subscriber) {
try {
LazyList<T> lazyList = query.forCurrentThread().listLazyUncached();
try {
for (T entity : lazyList) {
if (subscriber.isUnsubscribed()) {
break;
}
subscriber.onNext(entity);
}
} finally {
lazyList.close();
}
if (!subscriber.isUnsubscribed()) {
subscriber.onCompleted();
}
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
subscriber.onError(e);
}
}
});
代码示例来源:origin: greenrobot/greenDAO
public void testSublistUncached() {
ArrayList<TestEntity> list = insert(10);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build().listLazyUncached();
try {
assertIds(list.subList(2,7), listLazy.subList(2,7));
} catch (DaoException e) {
assertEquals("This operation only works with cached lazy lists", e.getMessage());
}
}
代码示例来源:origin: greenrobot/greenDAO
public void testIteratorUncached() {
ArrayList<TestEntity> list = insert(100);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build()
.listLazyUncached();
testIterator(list, listLazy, true);
assertFalse(listLazy.isClosed());
listLazy.close();
}
代码示例来源:origin: greenrobot/greenDAO
public void testGetAll100Uncached() {
ArrayList<TestEntity> list = insert(100);
LazyList<TestEntity> listLazy = dao.queryBuilder().orderAsc(Properties.SimpleInteger).build()
.listLazyUncached();
assertIds(list, listLazy);
assertFalse(listLazy.isClosed());
listLazy.close();
}
代码示例来源:origin: greenrobot/greenDAO
public void testAutoClose() {
insert(10);
LazyList<TestEntity> lazyList = dao.queryBuilder().build().listLazyUncached();
CloseableListIterator<TestEntity> iterator = lazyList.listIteratorAutoClose();
while (iterator.hasNext()) {
assertFalse(lazyList.isClosed());
iterator.next();
}
assertTrue(lazyList.isClosed());
}
代码示例来源:origin: greenrobot/greenDAO
public void testGetForCurrentThread_TwoThreads() throws InterruptedException {
insert(3);
createQueryFromOtherThread();
Query<TestEntity> query = queryFromOtherThread.forCurrentThread();
assertNotSame(queryFromOtherThread, query);
query.setLimit(10);
query.setOffset(0);
assertEquals(getSimpleInteger(1), (int) query.uniqueOrThrow().getSimpleInteger());
int expected = getSimpleInteger(2);
query.setParameter(0, expected);
assertEquals(expected, (int) query.list().get(0).getSimpleInteger());
assertEquals(expected, (int) query.listLazy().get(0).getSimpleInteger());
assertEquals(expected, (int) query.listLazyUncached().get(0).getSimpleInteger());
assertEquals(expected, (int) query.unique().getSimpleInteger());
assertEquals(expected, (int) query.uniqueOrThrow().getSimpleInteger());
}
代码示例来源:origin: greenrobot/greenDAO
public void testUncached() {
insert(1);
LazyList<TestEntity> listLazy = dao.queryBuilder().build().listLazyUncached();
assertFalse(listLazy.isEmpty());
assertFalse(listLazy.isClosed());
TestEntity entity1 = listLazy.get(0);
TestEntity entity2 = listLazy.get(0);
assertEquals(entity1.getId(), entity2.getId());
if (identityScopeForDao == null) {
assertNotSame(entity1, entity2);
} else {
assertSame(entity1, entity2);
}
assertFalse(listLazy.isClosed());
try {
listLazy.loadRemaining();
fail("Not empty");
} catch (DaoException expected) {
// Expected, OK
}
listLazy.close();
assertTrue(listLazy.isClosed());
}
代码示例来源:origin: greenrobot/greenDAO
queryFromOtherThread.listLazyUncached();
fail("Did not throw");
} catch (DaoException expected) {
代码示例来源:origin: org.greenrobot/greendao
/**
* Executes the query and returns the result as a list iterator; make sure to close it to close the underlying
* cursor. The cursor is closed once the iterator is fully iterated through.
*/
public CloseableListIterator<T> listIterator() {
return listLazyUncached().listIteratorAutoClose();
}
代码示例来源:origin: org.greenrobot/greendao
/**
* Shorthand for {@link QueryBuilder#build() build()}.{@link Query#listLazyUncached() listLazyUncached()}; see
* {@link Query#listLazyUncached()} for details. To execute a query more than once, you should build the query and
* keep the {@link Query} object for efficiency reasons.
*/
public LazyList<T> listLazyUncached() {
return build().listLazyUncached();
}
代码示例来源:origin: org.greenrobot/greendao
@Override
public void call(Subscriber<? super T> subscriber) {
try {
LazyList<T> lazyList = query.forCurrentThread().listLazyUncached();
try {
for (T entity : lazyList) {
if (subscriber.isUnsubscribed()) {
break;
}
subscriber.onNext(entity);
}
} finally {
lazyList.close();
}
if (!subscriber.isUnsubscribed()) {
subscriber.onCompleted();
}
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
subscriber.onError(e);
}
}
});
内容来源于网络,如有侵权,请联系作者删除!