private void prepareData() { List<TestEntity> targetEntities = new ArrayList<TestEntity>(); for (int i = 0; i < 10; i++) { TestEntity testEntity = new TestEntity(); testEntity.setSimpleInt(i + 1); testEntity.setSimpleStringNotNull("string-" + (i + 1)); targetEntities.add(testEntity); } testEntityDao.insertInTx(targetEntities); List<RelationEntity> entities = new ArrayList<RelationEntity>(); for (int i = 0; i < 10; i++) { RelationEntity entity = new RelationEntity(); entity.setSimpleString("entity-" + (i + 1)); entity.setTestNotNull(targetEntities.get(i)); entities.add(entity); } relationEntityDao.insertInTx(entities); }
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; }
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; }