/** 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; }
/** Internal query to resolve the "dateEntityList" to-many relationship of ToManyEntity. */ public List<DateEntity> _queryToManyEntity_DateEntityList(Long idToMany) { synchronized (this) { if (toManyEntity_DateEntityListQuery == null) { QueryBuilder<DateEntity> queryBuilder = queryBuilder(); queryBuilder.join(JoinManyToDateEntity.class, JoinManyToDateEntityDao.Properties.IdDate) .where(JoinManyToDateEntityDao.Properties.IdToMany.eq(idToMany)); toManyEntity_DateEntityListQuery = queryBuilder.build(); } } Query<DateEntity> query = toManyEntity_DateEntityListQuery.forCurrentThread(); query.setParameter(0, idToMany); return query.list(); }
public void testValues2() { DateEntity entity = createEntity(1l); long t1=32479875; long t2=976345942443435235l; entity.setDate(new Date(t1)); entity.setDateNotNull(new Date(t2)); dao.insert(entity); DateEntity reloaded = dao.load(entity.getId()); assertNotNull(reloaded.getDate()); assertNotNull(reloaded.getDateNotNull()); assertEquals(t1, reloaded.getDate().getTime()); assertEquals(t2, reloaded.getDateNotNull().getTime()); }
testEntityDao = new TestEntityDao(testEntityDaoConfig, this); relationEntityDao = new RelationEntityDao(relationEntityDaoConfig, this); dateEntityDao = new DateEntityDao(dateEntityDaoConfig, this); specialNamesEntityDao = new SpecialNamesEntityDao(specialNamesEntityDaoConfig, this); abcdefEntityDao = new AbcdefEntityDao(abcdefEntityDaoConfig, 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 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()); }