任何建议如何避免以下设置中的臭名昭着的LazyInitializationException(使用spring和hibernate):
@MessageMapping("/activate/foo")
@SendToUser("/queue/result")
public Result doit(Integer fooId) {
Foo foo = fooService.load(fooId); // via hibernate
result = ... // accessing foo outside a hibernate transaction
// therefore a LazyInitializationException is thrown
return result;
}
怎么办?
现在我投票给3,但看起来很酷......; - )