use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class JoinTest method testJoinOfJoin.
public void testJoinOfJoin() {
prepareData();
List<RelationEntity> relationEntities = relationEntityDao.loadAll();
relationEntities.get(2).setParent(relationEntities.get(4));
relationEntities.get(3).setParent(relationEntities.get(5));
relationEntities.get(7).setParent(relationEntities.get(5));
relationEntityDao.updateInTx(relationEntities);
QueryBuilder<RelationEntity> queryBuilder = relationEntityDao.queryBuilder();
Join<RelationEntity, RelationEntity> join1 = queryBuilder.join(RelationEntityDao.Properties.ParentId, RelationEntity.class);
queryBuilder.join(join1, RelationEntityDao.Properties.TestIdNotNull, TestEntity.class, Properties.Id).where(Properties.SimpleInt.lt(6));
Query<RelationEntity> query = queryBuilder.build();
RelationEntity entity = query.uniqueOrThrow();
assertEquals(relationEntities.get(2).getSimpleString(), entity.getSimpleString());
query.setParameter(0, 99);
assertEquals(3, query.list().size());
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class JoinTest method testJoinSimple.
public void testJoinSimple() {
prepareData();
QueryBuilder<RelationEntity> queryBuilder = createQueryBuilder(5);
RelationEntity unique = queryBuilder.uniqueOrThrow();
assertEquals("entity-5", unique.getSimpleString());
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class RelationEntityTest method testToOneLoadDeep.
public void testToOneLoadDeep() {
RelationEntity entity = insertEntityWithRelations(42l);
entity = dao.loadDeep(entity.getId());
assertTestEntity(entity);
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class RelationEntityTest method testToOneLoadDeepNull.
public void testToOneLoadDeepNull() {
RelationEntity entity = insertEntityWithRelations(42l);
entity.setParentId(null);
entity.setTestId(null);
dao.update(entity);
entity = dao.loadDeep(entity.getId());
assertNull(entity.getParent());
assertNull(entity.getTestEntity());
}
use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.
the class RelationEntityTest method testToOneClearKey.
public void testToOneClearKey() {
RelationEntity entity = insertEntityWithRelations(42l);
assertNotNull(entity.getParent());
entity.setParentId(null);
assertNull(entity.getParent());
}
Aggregations