gpt4 book ai didi

java - 在序列化期间从实体中删除代理代码

转载 作者:行者123 更新时间:2023-11-29 09:00:47 26 4
gpt4 key购买 nike

我有一个服务器和客户端,它们都是基于 Java 的,并且通过 RMI 相互通信。服务器的数据访问层是用 JPA 和 Hibernate 实现的,实体通常用作参数。

客户端没有 Hibernate 代码并且动态代码下载被禁用,因此当服务器向其客户端发送实体时,必须发送实际实体,而不是代理。此外,实体必须按原样发送,无需预加载所有延迟获取的属性,因为在大多数情况下,客户端永远不需要它们

是否可以使用 Hibernate 实现这些要求?

最佳答案

您可以获取查询中的所有属性

来自文档

If you are using property-level lazy fetching (with bytecode instrumentation), it is possible to force Hibernate to fetch the lazy properties in the first query immediately using fetch all properties.

from Document fetch all properties order by name

http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html

或者在你的映射中使用 eagle fetch...

关于java - 在序列化期间从实体中删除代理代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17619536/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com