@Override public List<T> call() throws Exception { return query.forCurrentThread().list(); } });
@Override public T call() throws Exception { return query.forCurrentThread().unique(); } });
public void run() { query.forCurrentThread(); } };
@Override public void run() { synchronized (query) { query.forCurrentThread().list(); } } };
@Override public void run() { query.forCurrentThread().list(); } };
@Override public void run() { query.forCurrentThread().list(); } };
/** Internal query to resolve the "children" to-many relationship of TreeEntity. */ public List<TreeEntity> _queryTreeEntity_Children(Long parentId) { synchronized (this) { if (treeEntity_ChildrenQuery == null) { QueryBuilder<TreeEntity> queryBuilder = queryBuilder(); queryBuilder.where(Properties.ParentId.eq(null)); treeEntity_ChildrenQuery = queryBuilder.build(); } } Query<TreeEntity> query = treeEntity_ChildrenQuery.forCurrentThread(); query.setParameter(0, parentId); return query.list(); }
/** Internal query to resolve the "toManyTarget2List" to-many relationship of RelationSource2. */ public List<ToManyTarget2> _queryRelationSource2_ToManyTarget2List(Long fkId) { synchronized (this) { if (relationSource2_ToManyTarget2ListQuery == null) { QueryBuilder<ToManyTarget2> queryBuilder = queryBuilder(); queryBuilder.where(Properties.FkId.eq(null)); relationSource2_ToManyTarget2ListQuery = queryBuilder.build(); } } Query<ToManyTarget2> query = relationSource2_ToManyTarget2ListQuery.forCurrentThread(); query.setParameter(0, fkId); return query.list(); }
@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); } } });
/** Internal query to resolve the "toManyTargetEntityList" to-many relationship of ToManyEntity. */ public List<ToManyTargetEntity> _queryToManyEntity_ToManyTargetEntityList(Long toManyId) { synchronized (this) { if (toManyEntity_ToManyTargetEntityListQuery == null) { QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder(); queryBuilder.where(Properties.ToManyId.eq(null)); queryBuilder.orderRaw("T.'_id' ASC"); toManyEntity_ToManyTargetEntityListQuery = queryBuilder.build(); } } Query<ToManyTargetEntity> query = toManyEntity_ToManyTargetEntityListQuery.forCurrentThread(); query.setParameter(0, toManyId); return query.list(); }
/** Internal query to resolve the "toManyByJoinProperty" to-many relationship of ToManyEntity. */ public List<ToManyTargetEntity> _queryToManyEntity_ToManyByJoinProperty(String targetJoinProperty) { synchronized (this) { if (toManyEntity_ToManyByJoinPropertyQuery == null) { QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder(); queryBuilder.where(Properties.TargetJoinProperty.eq(null)); queryBuilder.orderRaw("T.'_id' ASC"); toManyEntity_ToManyByJoinPropertyQuery = queryBuilder.build(); } } Query<ToManyTargetEntity> query = toManyEntity_ToManyByJoinPropertyQuery.forCurrentThread(); query.setParameter(0, targetJoinProperty); return query.list(); }
/** Internal query to resolve the "toManyDescList" to-many relationship of ToManyEntity. */ public List<ToManyTargetEntity> _queryToManyEntity_ToManyDescList(Long toManyIdDesc) { synchronized (this) { if (toManyEntity_ToManyDescListQuery == null) { QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder(); queryBuilder.where(Properties.ToManyIdDesc.eq(null)); queryBuilder.orderRaw("T.'_id' DESC"); toManyEntity_ToManyDescListQuery = queryBuilder.build(); } } Query<ToManyTargetEntity> query = toManyEntity_ToManyDescListQuery.forCurrentThread(); query.setParameter(0, toManyIdDesc); return query.list(); }
@Test // Testing the work around for Process.myTid() being always 0 in Robolectric public void testQueryForCurrentThread() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); final Query<MinimalEntity>[] queryHolder = new Query[1]; new Thread() { @Override public void run() { try { queryHolder[0] = minimalEntityDao.queryBuilder().build(); queryHolder[0].list(); } finally { latch.countDown(); } } }.start(); latch.await(); Query<MinimalEntity> query = queryHolder[0].forCurrentThread(); query.list(); }
/** Internal query to resolve the "dateEntityList" to-many relationship of ToManyEntity. */ public List<DateEntity> _queryToManyEntity_DateEntityList(Long idToMany) { synchronized (this) { if (toManyEntity_DateEntityListQuery == null) { QueryBuilder<DateEntity> queryBuilder = queryBuilder(); queryBuilder.join(JoinManyToDateEntity.class, JoinManyToDateEntityDao.Properties.IdDate) .where(JoinManyToDateEntityDao.Properties.IdToMany.eq(idToMany)); toManyEntity_DateEntityListQuery = queryBuilder.build(); } } Query<DateEntity> query = toManyEntity_DateEntityListQuery.forCurrentThread(); query.setParameter(0, idToMany); return query.list(); }
public void testGetForCurrentThread_SameInstance() { Query<TestEntity> query = dao.queryBuilder().build(); assertSame(query, query.forCurrentThread()); }
@Test public void testMockitoMocks() { mock(DaoMaster.class).newSession(); mock(DaoSession.class).getDatabase(); mock(Database.class).getRawDatabase(); mock(DatabaseStatement.class).execute(); mock(IdentityScope.class).clear(); mock(AbstractDao.class).queryBuilder(); mock(MinimalEntityDao.class).queryBuilder(); mock(MinimalEntity.class).getId(); mock(Query.class).forCurrentThread(); mock(QueryBuilder.class).build(); mock(CountQuery.class).forCurrentThread(); mock(DeleteQuery.class).forCurrentThread(); mock(Join.class).getTablePrefix(); mock(LazyList.class).getLoadedCount(); mock(WhereCondition.class).appendValuesTo(null); mock(Property.class).isNull(); mock(DaoException.class).getMessage(); }
/** Internal query to resolve the "toManyJoinTwo" to-many relationship of ToManyEntity. */ public List<ToManyTargetEntity> _queryToManyEntity_ToManyJoinTwo(Long toManyId, String targetJoinProperty) { synchronized (this) { if (toManyEntity_ToManyJoinTwoQuery == null) { QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder(); queryBuilder.where(Properties.ToManyId.eq(null)); queryBuilder.where(Properties.TargetJoinProperty.eq(null)); queryBuilder.orderRaw("T.'TARGET_JOIN_PROPERTY' DESC,T.'_id' DESC"); toManyEntity_ToManyJoinTwoQuery = queryBuilder.build(); } } Query<ToManyTargetEntity> query = toManyEntity_ToManyJoinTwoQuery.forCurrentThread(); query.setParameter(0, toManyId); query.setParameter(1, targetJoinProperty); return query.list(); }
break; case QueryList: operation.result = ((Query) operation.parameter).forCurrentThread().list(); break; case QueryUnique: operation.result = ((Query) operation.parameter).forCurrentThread().unique(); break; case DeleteByKey:
public void testGetForCurrentThread_ParametersAreReset() { insert(3); int value = getSimpleInteger(1); Query<TestEntity> query = dao.queryBuilder().where(Properties.SimpleInteger.eq(value)).build(); query.setParameter(0, value + 1); TestEntity entityFor2 = query.unique(); assertEquals(value + 1, (int) entityFor2.getSimpleInteger()); query = query.forCurrentThread(); assertNotNull(query.unique()); }
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()); }