Closed fantouch closed 11 years ago
为什么我还是有Parent.getChildren().getList().size()总为0的问题呢?
代码如下:
Parent parent = new Parent();
parent.setName("臭臭");
parent.setId(22);
Child child1 = new Child();
child1.setName("满宝臭臭");
child1.setParent(parent);
Child child2 = new Child();
child2.setName("满宝笨笨");
child1.setParent(parent);
List<Child> value = new ArrayList<Child>();
value.add(child1);
value.add(child2);
OneToManyLazyLoader<Parent, Child> children = new OneToManyLazyLoader<Parent, Child>(parent, Parent.class, Child.class, db);
children.setList(value);
parent.setChildren(children);
db.save(parent);//删除表后出错
db.save(child1);
db.save(child2);
List<Parent> all = db.findAll(Parent.class);
for( Parent item : all){
if(item.getChildren ().getList().size()>0)
System.out.println(item.getName() + item.getChildren().getList().get(0).getName());
else
{
System.out.println("------------------失败--------------------");
System.out.println(item.getChildren ().getList().size());
}
}
修复
FinalDb.loadOneToMany(T entity, Class<T> clazz, Class<?>... findClass)
方法无效的问题,顺带修复OneToMany懒加载中
Parent.getChildren().getList().size()
总为0的问题.