org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
OneToMany 应该是这样的吧
class Topic
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
public List
return replys;
}
class Reply
@ManyToOne
public Topic getTopic() {
return topic;
}
这样配置是完全正确的,但是懒加载必须在session关闭前显示调用xxx.getxxxlist();
fetch = fetchtype.lazy是说在你得到xxx的时候是否顺便把xxxlist加载到缓存中
并不代表你在session关闭后还存在!
当不需要懒加载时候 fetch = fetchtype.eger可以提高执行效率
另外在many端是不用fetch = fetchtype.lazy 默认就是这种配置