Search in sources :

Example 1 with RelationEntity

use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.

the class JoinTest method testJoinSimpleParameterValue.

public void testJoinSimpleParameterValue() {
    prepareData();
    QueryBuilder<RelationEntity> queryBuilder = createQueryBuilder(-1);
    Query<RelationEntity> query = queryBuilder.build();
    for (int i = 0; i < 10; i++) {
        query.setParameter(0, i + 1);
        RelationEntity unique = query.uniqueOrThrow();
        assertEquals("entity-" + (i + 1), unique.getSimpleString());
    }
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 2 with RelationEntity

use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.

the class RelationEntityTest method createEntity.

@Override
protected RelationEntity createEntity(Long key) {
    RelationEntity entity = new RelationEntity();
    entity.setId(key);
    return entity;
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 3 with RelationEntity

use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.

the class RelationEntityTest method testToOneSelf.

public void testToOneSelf() {
    RelationEntity entity = createEntity(1l);
    dao.insert(entity);
    entity = dao.load(1l);
    assertNull(entity.getParent());
    entity.setParentId(entity.getId());
    dao.update(entity);
    entity = dao.load(1l);
    RelationEntity parent = entity.getParent();
    assertEquals(entity.getId(), parent.getId());
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 4 with RelationEntity

use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.

the class RelationEntityTest method testToOne.

public void testToOne() {
    RelationEntity entity = insertEntityWithRelations(42l);
    entity = dao.load(entity.getId());
    assertTestEntity(entity);
}
Also used : RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Example 5 with RelationEntity

use of org.greenrobot.greendao.daotest.RelationEntity in project greenDAO by greenrobot.

the class RelationEntityTest method testToOneUpdateKey.

public void testToOneUpdateKey() {
    RelationEntity entity = insertEntityWithRelations(42l);
    TestEntity testEntity = entity.getTestEntity();
    RelationEntity entity2 = insertEntityWithRelations(43l);
    TestEntity testEntity2 = entity2.getTestEntity();
    entity.setTestId(testEntity2.getId());
    assertEquals(testEntity2.getId(), entity.getTestEntity().getId());
    entity.setTestId(null);
    assertNull(entity.getTestEntity());
    entity.setTestId(testEntity.getId());
    assertEquals(testEntity.getId(), entity.getTestEntity().getId());
}
Also used : TestEntity(org.greenrobot.greendao.daotest.TestEntity) RelationEntity(org.greenrobot.greendao.daotest.RelationEntity)

Aggregations

RelationEntity (org.greenrobot.greendao.daotest.RelationEntity)20 TestEntity (org.greenrobot.greendao.daotest.TestEntity)5 ArrayList (java.util.ArrayList)1