@Entity
public class Spaces {
// 所属人
private Owner owner; // id name ...等属性。 @OneToOne(fetch=FetchType.EAGER)
public Owner getOwner() {
return owner;
} public void setOwner(Owner owner) {
this.owner = owner;
}}
List<Spaces> list=session.createQuery("from Spaces").list();function(list){
$.each(list,function(i,n){
//n.owner.name error: Cannot read property 'name' of null
})
}
已经级联查询了,还是不能得到。很奇怪!
不是空 10条数据
list是10条,owner为空,否则也不会报Cannot read property 'name' of null了
不是空 10条数据
list是10条,owner为空,否则也不会报Cannot read property 'name' of null了不写name则是object。而且在后头输出成功,前台才出这个错