ColdFusion 9 ORM/Hibernate 和远程处理

发布于 2024-08-27 01:43:12 字数 65 浏览 2 评论 0原文

为什么我的 cfc 方法(返回 JSON 格式或通过远程处理调用时)会返回所有相关对象,而不管属性上的惰性设置如何?

Why does my cfc method (when returning JSON format or called via remoting) return all related objects regardless of the lazy setting on the property?

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

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

发布评论

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

评论(1

鸩远一方 2024-09-03 01:43:12

我的猜测是,当 CF 将这些对象序列化为 JSON 时,它被迫调用相关对象的 getter,这反过来又导致它们在数据库中查找。 “lazy”属性控制是否在检索主对象期间检索相关对象,或者延迟到您实际请求它们为止。在这种情况下,当序列化对象时,相关对象要么根据返回的 JSON 进行查找,要么不根据返回的 JSON 进行查找,因此无论惰性设置如何,它们都会返回。

基本上,如果您有棒球运动员和球队的数据结构,如果为选定球员(即乔什·贝克特)返回的 JSON 调用有关球队(即红袜队)的信息,则无论惰性属性设置如何,该球队对象都会当您获取玩家对象或请求与玩家相关的团队对象时检索。

有道理吗?

My guess is that when CF serializes those objects into JSON, it is forced to call the getters for the related objects, which in turn causes them to looked up in the database. The "lazy" property controls whether or not related objects are retrieved during the retrieval of the main objects or delayed until you actually request them. In this case, when serializing the object, the related objects are either looked up or not based on the JSON returned, so regardless of the lazy setting, they'll come back.

Basically, if you have a data structure of baseball players and teams, if the JSON returned for a selected player (i.e. Josh Beckett) calls for info about the team (i.e. Red Sox), regardless of the lazy property setting, that team object will either be retrieved when you get the player object or when you ask for the team object that relates to the player.

Make sense?

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