Hibernate代理序列化并在客户端接收

发布于 2024-08-29 15:23:07 字数 143 浏览 4 评论 0原文

我不了解生成的代理类对象(CGLib增强的POJO)如何传输到远程客户端并仍然保留其生成Lazy Init的能力。例外情况。

这是否意味着存在某种契约,即某种类(代理)的所有转移对象将再次重新实例化为代理?客户端从哪里获取这些生成的类?抱歉,我完全不明白。

I lack understanding of how does the generated proxy class object (CGLib enhanced POJO) is transferred to the remote client and still retains its ability to generate Lazy Init. Exceptions.

Does that mean that there is some kind of contract that all the transferred objects of some kind of class (a proxy) will be reinstantiated as proxies again? Where does the client obtain those generated classes? Sorry, but I totally do not understand.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黯然 2024-09-05 15:23:07

因为您的远程客户端应用程序现在依赖于 Hibernate。如果您的远程客户端的类路径上没有 Hibernate,您将收到 NoClassDefFoundError。这表明 Hibernate 的抽象有多么漏洞。

基本上,不要通过网络传递对象 - 传递消息(如果您愿意,可以使用消息来创建对象)。

Because your remote client application now has a dependency on Hibernate. If your remote client doesn't have Hibernate on the classpath you'll get a NoClassDefFoundError. This demonstrates how leaky the abstraction is with Hibernate.

Basically, don't pass objects across the network - pass messages (which can then be used to create objects, if you so wish).

走野 2024-09-05 15:23:07

代理未初始化。当它们被转移时,它们会丢失最初与之关联的Session。因此,当尝试在远程端初始化它们时,逻辑上会失败。

您可以在发送它们之前使用 Hibernate.initialize(aProxy) 完全初始化它们。

有关详细信息,请检查 这个答案

The proxies are uninitialized. When they are transferred, they loose the Session they were originally associated with. So when an attempt is made to initialize them on the remote side, it logically fails.

You can initialize them fully before sending them, using Hibernate.initialize(aProxy)

For more information check this answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文