开发者

JSF 2.0 entity manager Transaction problems during render phase

When rendering the final view during the render phase, hibernate throws

failed to lazil开发者_开发问答y initialize a collection of role

And I suppose this is because there is no transaction to fetch lazy data.

In this case what is the best possible solution either than eagerly loading the data.

can I extend the transaction to cover this phase

NB. I'm not using EJBs so dont have Container Managed Transactions.

Any ideas?


Depending on the Hibernate version you are using, you can enable the eager fetching for this particular query. If the version of Hibernate you are using does not supports that, you'll have to pre-fetch it manually, by calling "getRoles" before getting into the view. One last solution is to use the "open session in view" pattern: http://community.jboss.org/wiki/OpenSessioninView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜