/** * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}. * Entity must attached to an entity context. */ @Generated public void delete() { __throwIfDetached(); myDao.delete(this); }
/** * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}. * Entity must attached to an entity context. */ @Generated public void refresh() { __throwIfDetached(); myDao.refresh(this); }
/** * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}. * Entity must attached to an entity context. */ @Generated public void update() { __throwIfDetached(); myDao.update(this); }
public void testToManyOrder() { prepareToMany(1, 3); ToManyEntity testEntity = toManyEntityDao.load(1L); List<ToManyTargetEntity> resolvedToManyAsc = testEntity.getToManyTargetEntityList(); List<ToManyTargetEntity> resolvedToManyDesc = testEntity.getToManyDescList(); assertNotSame(resolvedToManyAsc, resolvedToManyDesc); assertEquals(resolvedToManyAsc.get(0).getId(), resolvedToManyDesc.get(2).getId()); assertSame(resolvedToManyAsc.get(0), resolvedToManyDesc.get(2)); assertSame(resolvedToManyAsc.get(1), resolvedToManyDesc.get(1)); assertSame(resolvedToManyAsc.get(2), resolvedToManyDesc.get(0)); }
public void testConcurrentResolveToMany() throws InterruptedException { final ToManyEntity entity = new ToManyEntity(); ToManyEntityDao toManyDao = daoSession.getToManyEntityDao(); toManyDao.insert(entity); Runnable runnable1 = new Runnable() { @Override public void run() { entity.getToManyTargetEntityList(); } }; initThreads(runnable1); doTx(new Runnable() { @Override public void run() { entity.getToManyTargetEntityList(); } }); latchThreadsDone.await(); }
abcdefEntityDao = new AbcdefEntityDao(abcdefEntityDaoConfig, this); toManyTargetEntityDao = new ToManyTargetEntityDao(toManyTargetEntityDaoConfig, this); toManyEntityDao = new ToManyEntityDao(toManyEntityDaoConfig, this); joinManyToDateEntityDao = new JoinManyToDateEntityDao(joinManyToDateEntityDaoConfig, this); treeEntityDao = new TreeEntityDao(treeEntityDaoConfig, this);
/** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { SimpleEntityDao.createTable(db, ifNotExists); SimpleEntityNotNullDao.createTable(db, ifNotExists); TestEntityDao.createTable(db, ifNotExists); RelationEntityDao.createTable(db, ifNotExists); DateEntityDao.createTable(db, ifNotExists); SpecialNamesEntityDao.createTable(db, ifNotExists); AbcdefEntityDao.createTable(db, ifNotExists); ToManyTargetEntityDao.createTable(db, ifNotExists); ToManyEntityDao.createTable(db, ifNotExists); JoinManyToDateEntityDao.createTable(db, ifNotExists); TreeEntityDao.createTable(db, ifNotExists); AnActiveEntityDao.createTable(db, ifNotExists); ExtendsImplementsEntityDao.createTable(db, ifNotExists); StringKeyValueEntityDao.createTable(db, ifNotExists); AutoincrementEntityDao.createTable(db, ifNotExists); CustomTypeEntityDao.createTable(db, ifNotExists); IndexedStringEntityDao.createTable(db, ifNotExists); }
/** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { SimpleEntityDao.dropTable(db, ifExists); SimpleEntityNotNullDao.dropTable(db, ifExists); TestEntityDao.dropTable(db, ifExists); RelationEntityDao.dropTable(db, ifExists); DateEntityDao.dropTable(db, ifExists); SpecialNamesEntityDao.dropTable(db, ifExists); AbcdefEntityDao.dropTable(db, ifExists); ToManyTargetEntityDao.dropTable(db, ifExists); ToManyEntityDao.dropTable(db, ifExists); JoinManyToDateEntityDao.dropTable(db, ifExists); TreeEntityDao.dropTable(db, ifExists); AnActiveEntityDao.dropTable(db, ifExists); ExtendsImplementsEntityDao.dropTable(db, ifExists); StringKeyValueEntityDao.dropTable(db, ifExists); AutoincrementEntityDao.dropTable(db, ifExists); CustomTypeEntityDao.dropTable(db, ifExists); IndexedStringEntityDao.dropTable(db, ifExists); }
public void runTestToManyBasics(long id, int count) { ToManyTargetEntity[] targetEntities = prepareToMany(id, count); ToManyEntity testEntity = toManyEntityDao.load(id); List<ToManyTargetEntity> resolvedToMany = testEntity.getToManyTargetEntityList(); assertSameEntities(targetEntities, resolvedToMany); }
public void testGetToManyTwice() { prepareToMany(1, 3); ToManyEntity testEntity = toManyEntityDao.load(1L); List<ToManyTargetEntity> resolvedToMany1 = testEntity.getToManyTargetEntityList(); List<ToManyTargetEntity> resolvedToMany2 = testEntity.getToManyTargetEntityList(); assertSame(resolvedToMany1, resolvedToMany2); }
public void testResetToMany() { ToManyTargetEntity[] targetEntities = prepareToMany(1, 3); ToManyEntity testEntity = toManyEntityDao.load(1L); List<ToManyTargetEntity> resolvedToMany1 = testEntity.getToManyTargetEntityList(); testEntity.resetToManyTargetEntityList(); List<ToManyTargetEntity> resolvedToMany2 = testEntity.getToManyTargetEntityList(); assertNotSame(resolvedToMany1, resolvedToMany2); assertSameEntities(targetEntities, resolvedToMany2); }
public void testTwoJoinProperty() { ToManyEntity entity = new ToManyEntity(1L); entity.setSourceJoinProperty("JOIN ME"); daoSession.insert(entity); insertTargetEntities(1L, 3, "JOIN ME"); ToManyEntity testEntity = toManyEntityDao.load(1L); List<ToManyTargetEntity> targetEntities = testEntity.getToManyJoinTwo(); assertEquals(3, targetEntities.size()); ToManyTargetEntity middleEntity = targetEntities.get(1); middleEntity.setTargetJoinProperty("DON'T JOIN ME"); toManyTargetEntityDao.update(middleEntity); testEntity.resetToManyJoinTwo(); targetEntities = testEntity.getToManyJoinTwo(); assertEquals(2, targetEntities.size()); assertFalse(middleEntity.getId() == targetEntities.get(0).getId()); assertFalse(middleEntity.getId() == targetEntities.get(1).getId()); }
public void testJoinProperty() { ToManyEntity entity = new ToManyEntity(1L); entity.setSourceJoinProperty("JOIN ME"); daoSession.insert(entity); insertTargetEntities(null, 3, "JOIN ME"); ToManyEntity testEntity = toManyEntityDao.load(1L); List<ToManyTargetEntity> targetEntities = testEntity.getToManyByJoinProperty(); assertEquals(3, targetEntities.size()); ToManyTargetEntity middleEntity = targetEntities.get(1); middleEntity.setTargetJoinProperty("DON'T JOIN ME"); toManyTargetEntityDao.update(middleEntity); testEntity.resetToManyByJoinProperty(); targetEntities = testEntity.getToManyByJoinProperty(); assertEquals(2, targetEntities.size()); assertFalse(middleEntity.getId() == targetEntities.get(0).getId()); assertFalse(middleEntity.getId() == targetEntities.get(1).getId()); }
public void testChangeResetToMany() { prepareToMany(1, 3); ToManyEntity testEntity = toManyEntityDao.load(1L); List<ToManyTargetEntity> resolvedToMany1 = testEntity.getToManyTargetEntityList(); testEntity.resetToManyTargetEntityList(); ToManyTargetEntity newEntity = new ToManyTargetEntity(); newEntity.setToManyId(1L); daoSession.insert(newEntity); List<ToManyTargetEntity> resolvedToMany2 = testEntity.getToManyTargetEntityList(); assertNotSame(resolvedToMany1, resolvedToMany2); assertEquals(resolvedToMany1.size() + 1, resolvedToMany2.size()); testEntity.resetToManyTargetEntityList(); toManyTargetEntityDao.deleteAll(); List<ToManyTargetEntity> resolvedToMany3 = testEntity.getToManyTargetEntityList(); assertEquals(0, resolvedToMany3.size()); }