/** called by internal mechanisms, do not call yourself. */ @Generated public void __setDaoSession(DaoSession daoSession) { this.daoSession = daoSession; myDao = daoSession != null ? daoSession.getAnActiveEntityDao() : null; }
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */ @Generated public List<DateEntity> getDateEntityList() { if (dateEntityList == null) { __throwIfDetached(); DateEntityDao targetDao = daoSession.getDateEntityDao(); List<DateEntity> dateEntityListNew = targetDao._queryToManyEntity_DateEntityList(id); synchronized (this) { if(dateEntityList == null) { dateEntityList = dateEntityListNew; } } } return dateEntityList; }
@Override protected void setUp() throws Exception { super.setUp(); QueryBuilder.LOG_SQL = true; QueryBuilder.LOG_VALUES = true; testEntityDao = daoSession.getTestEntityDao(); relationEntityDao = daoSession.getRelationEntityDao(); }
@Override protected void setUp() throws Exception { super.setUp(); toManyEntityDao = daoSession.getToManyEntityDao(); toManyTargetEntityDao = daoSession.getToManyTargetEntityDao(); }
/** 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; }
/** called by internal mechanisms, do not call yourself. */ @Generated public void __setDaoSession(DaoSession daoSession) { this.daoSession = daoSession; myDao = daoSession != null ? daoSession.getTreeEntityDao() : null; }
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */ @Generated public List<ToManyTargetEntity> getToManyJoinTwo() { if (toManyJoinTwo == null) { __throwIfDetached(); ToManyTargetEntityDao targetDao = daoSession.getToManyTargetEntityDao(); List<ToManyTargetEntity> toManyJoinTwoNew = targetDao._queryToManyEntity_ToManyJoinTwo(id, sourceJoinProperty); synchronized (this) { if(toManyJoinTwo == null) { toManyJoinTwo = toManyJoinTwoNew; } } } return toManyJoinTwo; }
/** called by internal mechanisms, do not call yourself. */ @Generated public void __setDaoSession(DaoSession daoSession) { this.daoSession = daoSession; myDao = daoSession != null ? daoSession.getRelationEntityDao() : null; }
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; }
public void testToManyWithJoin() { ToManyEntity entity = new ToManyEntity(1L); daoSession.insert(entity); List<DateEntity> dateEntities = entity.getDateEntityList(); assertEquals(0, dateEntities.size()); DateEntityDao dateDao = daoSession.getDateEntityDao(); Date now = new Date(); DateEntity date1 = new DateEntity(1L, null, now); DateEntity date2 = new DateEntity(2L, null, now); DateEntity date3 = new DateEntity(3L, null, now); DateEntity date4 = new DateEntity(4L, null, now); dateDao.insertInTx(date1, date2, date3, date4); daoSession.insert(new JoinManyToDateEntity(1L,2L,1L)); daoSession.insert(new JoinManyToDateEntity(2L,1L,3L)); entity.resetDateEntityList(); dateEntities = entity.getDateEntityList(); assertEquals(1, dateEntities.size()); assertEquals(3L, (long) dateEntities.get(0).getId()); daoSession.insert(new JoinManyToDateEntity(3L, 1L, 4L)); entity.resetDateEntityList(); dateEntities = entity.getDateEntityList(); assertEquals(2, dateEntities.size()); }
/** called by internal mechanisms, do not call yourself. */ @Generated public void __setDaoSession(DaoSession daoSession) { this.daoSession = daoSession; myDao = daoSession != null ? daoSession.getToManyEntityDao() : null; }
public void testAutoincrement() { AutoincrementEntity entity = new AutoincrementEntity(); daoSession.insert(entity); Long id1 = entity.getId(); assertNotNull(id1); daoSession.delete(entity); AutoincrementEntity entity2 = new AutoincrementEntity(); daoSession.insert(entity2); assertEquals(id1 + 1, (long) entity2.getId()); }
public void testOperationGetResult() { SimpleEntity entity = new SimpleEntity(); entity.setSimpleString("heho"); daoSession.insert(entity); daoSession.clear(); AsyncOperation operation = asyncSession.load(SimpleEntity.class, entity.getId()); SimpleEntity result = (SimpleEntity) operation.getResult(); assertTrue(operation.isCompleted()); assertTrue(operation.isCompletedSucessfully()); assertNotNull(result); assertNotSame(entity, result); assertEquals(entity.getId(), result.getId()); assertEquals(entity.getSimpleString(), result.getSimpleString()); }
public void testMergeInsertAndUpdate() { SimpleEntity entity = new SimpleEntity(); entity.setId(42l); entity.setSimpleString("heho"); SimpleEntity entity2 = new SimpleEntity(); entity2.setId(42l); entity2.setSimpleString("updated"); AsyncOperation op1 = asyncSession.insert(entity, AsyncOperation.FLAG_MERGE_TX); AsyncOperation op2 = asyncSession.update(entity2, AsyncOperation.FLAG_MERGE_TX); assertWaitForCompletion1Sec(); daoSession.clear(); SimpleEntity entity3 = daoSession.load(SimpleEntity.class, 42l); assertNotNull(entity3); assertEquals(entity2.getSimpleString(), entity3.getSimpleString()); assertEquals(2, op1.getMergedOperationsCount()); assertEquals(2, op2.getMergedOperationsCount()); }
public void testNavigateTreeFromMiddle() { createTree(); daoSession.clear(); TreeEntity child1 = treeEntityDao.load(11l); assertEquals(1, child1.getChildren().size()); TreeEntity child1Child = child1.getChildren().get(0); assertEquals(101, child1Child.getId().longValue()); assertEquals(0, child1Child.getChildren().size()); TreeEntity root = child1.getParent(); assertEquals(1l, root.getId().longValue()); assertEquals(2, root.getChildren().size()); assertNull(root.getParent()); }
public DaoSession newSession() { return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); }
/** 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.getTreeEntityDao().getAllColumns()); builder.append(" FROM TREE_ENTITY T"); builder.append(" LEFT JOIN TREE_ENTITY T0 ON T.\"PARENT_ID\"=T0.\"_id\""); builder.append(' '); selectDeep = builder.toString(); } return selectDeep; }
public void testAsyncUpdate() { SimpleEntity entity = new SimpleEntity(); entity.setSimpleString("heho"); daoSession.insert(entity); entity.setSimpleString("updated"); AsyncOperation operation = asyncSession.update(entity); assertWaitForCompletion1Sec(); daoSession.clear(); SimpleEntity entity2 = daoSession.load(SimpleEntity.class, entity.getId()); assertNotNull(entity2); assertEquals("updated", entity2.getSimpleString()); assertFalse(operation.isFailed()); assertSingleOperationCompleted(operation); }