`
SilverRing
  • 浏览: 70835 次
社区版块
存档分类
最新评论

[Hibernate] one cause of LazyInitializationException

阅读更多
Sometimes a LazyInitializationException will be thrown on getHibernateTemplate().load().

Reason being when using load(), Hibernate simply retrieves you a Proxy, which has only the id set, rest of the fields being queried from database when needed. At that time, the hibernate session might have been closed.

A quick fix: replace .load() with .get(). It'll fetch the result immediately.
分享到:
评论
1 楼 DavyLee 2011-01-28  
简直扯淡,get和load都报同样的错!

相关推荐

Global site tag (gtag.js) - Google Analytics