模块通过EJB的揭露功能。如何处理模块之间Hibernate的懒加载? [英] Modules exposing functionality via EJBs. How to handle Hibernate lazy loading between modules?

查看:178
本文介绍了模块通过EJB的揭露功能。如何处理模块之间Hibernate的懒加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说,一个应用程序被分成模块,每个模块通过EJB的揭露功能。如果模块A使得在返回休眠通过检索的对象模块B的EJB方法的调用,那么模块A将无法调用该对象的延迟加载方法,因为会话不再存在。如何处理这种情况?

Lets say an application is broken into modules, each module exposing functionality via EJBs. If module A makes a call to an EJB method in module B which returns an object retrieved via Hibernate, then module A will not be able to call a lazy loading method of that object because the session is no longer there. How to handle this kind of situation?

推荐答案

我想出了这个最后的决定。还没有尝试过,但我认为它会奏效。问题是

I came up with this final decision. Haven't tried it yet but I think it will work. The problem was

如果模块A使得在模块B EJB方法返回通过Hibernate的检索对象的调用,那么模块A将无法调用该对象的延迟加载方法,因为会话不再存在。

If module A makes a call to an EJB method in module B which returns an object retrieved via Hibernate, then module A will not be able to call a lazy loading method of that object because the session is no longer there.

因此​​,为了克服这个问题,模块B将只返回该对象和模块A的主键将检索经由休眠的对象。这样一个模块就可以调用该对象的延迟加载的方法。

So in order to overcome this, module B will return only the primary key of the object and module A will retrieve the object via Hibernate. This way module A will be able to call lazy loaded methods of the object.

这篇关于模块通过EJB的揭露功能。如何处理模块之间Hibernate的懒加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆