/** To-one relationship, resolved on first access. */ @Generated public TestEntity getTestNotNull() { long __key = this.testIdNotNull; if (testNotNull__resolvedKey == null || !testNotNull__resolvedKey.equals(__key)) { __throwIfDetached(); TestEntityDao targetDao = daoSession.getTestEntityDao(); TestEntity testNotNullNew = targetDao.load(__key); synchronized (this) { testNotNull = testNotNullNew; testNotNull__resolvedKey = __key; } } return testNotNull; }
/** To-one relationship, resolved on first access. */ @Generated public TestEntity getTestEntity() { Long __key = this.testId; if (testEntity__resolvedKey == null || !testEntity__resolvedKey.equals(__key)) { __throwIfDetached(); TestEntityDao targetDao = daoSession.getTestEntityDao(); TestEntity testEntityNew = targetDao.load(__key); synchronized (this) { testEntity = testEntityNew; testEntity__resolvedKey = __key; } } return testEntity; }
/** To-one relationship, resolved on first access. */ @Generated public TestEntity getTestWithoutProperty() { if (testWithoutProperty != null || !testWithoutProperty__refreshed) { __throwIfDetached(); TestEntityDao targetDao = daoSession.getTestEntityDao(); targetDao.refresh(testWithoutProperty); testWithoutProperty__refreshed = true; } return testWithoutProperty; }
protected String getSelectDeep() { if (selectDeep == null) { StringBuilder builder = new StringBuilder("SELECT "); SqlUtils.appendColumns(builder, "T", getAllColumns()); builder.append(','); SqlUtils.appendColumns(builder, "T0", daoSession.getRelationEntityDao().getAllColumns()); builder.append(','); SqlUtils.appendColumns(builder, "T1", daoSession.getTestEntityDao().getAllColumns()); builder.append(','); SqlUtils.appendColumns(builder, "T2", daoSession.getTestEntityDao().getAllColumns()); builder.append(','); SqlUtils.appendColumns(builder, "T3", daoSession.getTestEntityDao().getAllColumns()); builder.append(" FROM RELATION_ENTITY T"); builder.append(" LEFT JOIN RELATION_ENTITY T0 ON T.\"PARENT_ID\"=T0.\"_id\""); builder.append(" LEFT JOIN TEST_ENTITY T1 ON T.\"TEST_ID\"=T1.\"_id\""); builder.append(" LEFT JOIN TEST_ENTITY T2 ON T.\"TEST_ID_NOT_NULL\"=T2.\"_id\""); builder.append(" LEFT JOIN TEST_ENTITY T3 ON T.\"WITHOUT_PROPERTY_TEST_ID\"=T3.\"_id\""); builder.append(' '); selectDeep = builder.toString(); } return selectDeep; }
@Override protected void setUp() throws Exception { super.setUp(); dao = daoSession.getTestEntityDao(); }
protected RelationEntity loadCurrentDeep(Cursor cursor, boolean lock) { RelationEntity entity = loadCurrent(cursor, 0, lock); int offset = getAllColumns().length; RelationEntity parent = loadCurrentOther(daoSession.getRelationEntityDao(), cursor, offset); entity.setParent(parent); offset += daoSession.getRelationEntityDao().getAllColumns().length; TestEntity testEntity = loadCurrentOther(daoSession.getTestEntityDao(), cursor, offset); entity.setTestEntity(testEntity); offset += daoSession.getTestEntityDao().getAllColumns().length; TestEntity testNotNull = loadCurrentOther(daoSession.getTestEntityDao(), cursor, offset); if(testNotNull != null) { entity.setTestNotNull(testNotNull); } offset += daoSession.getTestEntityDao().getAllColumns().length; TestEntity testWithoutProperty = loadCurrentOther(daoSession.getTestEntityDao(), cursor, offset); entity.setTestWithoutProperty(testWithoutProperty); return entity; }
protected TestEntity insertEntity(String simpleStringNotNull) { return RxTestHelper.insertEntity(daoSession.getTestEntityDao(), simpleStringNotNull); }
@Override protected void setUp() throws Exception { super.setUp(); QueryBuilder.LOG_SQL = true; QueryBuilder.LOG_VALUES = true; testEntityDao = daoSession.getTestEntityDao(); relationEntityDao = daoSession.getRelationEntityDao(); }
protected List<TestEntity> insertEntities(int count) { List<TestEntity> entities = new ArrayList<>(count); for (int i = 0; i < count; i++) { TestEntity entity = RxTestHelper.createEntity("My entity "); entity.setSimpleInt(i); entities.add(entity); } daoSession.getTestEntityDao().insertInTx(entities); return entities; }
private <T> TestSubscriber<T> assertTxExecuted(Observable<T> observable) { TestSubscriber<T> testSubscriber = RxTestHelper.awaitTestSubscriber(observable); assertEquals(1, testSubscriber.getValueCount()); daoSession.clear(); List<TestEntity> all = daoSession.getTestEntityDao().loadAll(); assertEquals(1, all.size()); assertEquals("hello", all.get(0).getSimpleStringNotNull()); assertEquals("world", all.get(0).getSimpleString()); return testSubscriber; }
@Override protected void setUp() throws Exception { super.setUp(); query = daoSession.getTestEntityDao().queryBuilder().where(Properties.SimpleInt.lt(10)).build(); rxQuery = query.__InternalRx(); }
public void _testLoadAll() throws InterruptedException { dao = daoSession.getTestEntityDao(); List<TestEntity> entities = new ArrayList<>(); for (int i = 0; i < 10000; i++) {
public void testOneByOneUnsubscribe() { insertEntities(1000); RxQuery<TestEntity> bigQuery = daoSession.getTestEntityDao().queryBuilder().rx(); TestSubscriber<TestEntity> testSubscriber = new TestSubscriber<>(); Observable<TestEntity> observable = bigQuery.oneByOne(); Subscription subscription = observable.subscribe(testSubscriber); subscription.unsubscribe(); testSubscriber.assertUnsubscribed(); int count = testSubscriber.getValueCount(); testSubscriber.awaitTerminalEvent(100, TimeUnit.MILLISECONDS); int count2 = testSubscriber.getValueCount(); DaoLog.d("Count 1: " + count + " vs. count 2: " + count2); // Not strictly multi-threading correct, but anyway: assertTrue(count2 < 1000); }
protected RelationEntity insertEntityWithRelations(Long testEntityId) { TestEntity testEntity = daoSession.getTestEntityDao().load(testEntityId); if (testEntity == null) { testEntity = new TestEntity(testEntityId); testEntity.setSimpleStringNotNull("mytest"); daoSession.getTestEntityDao().insert(testEntity); } RelationEntity parentEntity = createEntity(null); parentEntity.setSimpleString("I'm a parent"); parentEntity.setTestNotNull(testEntity); dao.insert(parentEntity); RelationEntity entity = createEntity(null); entity.setTestId(testEntityId); entity.setParentId(parentEntity.getId()); entity.setSimpleString("findMe"); entity.setTestNotNull(testEntity); dao.insert(entity); return entity; }