[关闭]
@big-bear 2016-02-02T10:45:37.000000Z 字数 383 阅读 1137

hibernate 懒加载

hibernate


启用和关闭懒加载

down vote
The reason is that when you use lazy load, the session is closed.
There are two solutions.
Don't use lazy load.

  1. Set lazy=false in XML or Set @OneToMany(fetch = FetchType.EAGER) In annotation.

Use lazy load.

  1. Set lazy=true in XML or Set @OneToMany(fetch = FetchType.LAZY) In annotation.

and add OpenSessionInViewFilter filter in your web.xml
Detail See my post.
http://stackoverflow.com/a/27286187/1808417

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注