GWT RequestFactory ValueProxy 关系
假设我有一个数据库,类型为 A
和 B
。 A
是一个 EntityProxy
,其中包含 B
列表,而 B
是一个 ValueProxy
>。我使用GWT的RequestFactory通过id查询A
。当我使用 RequestFactory 查询 A
时,我可以像这样访问 B
列表:A.getB()
,因为 B
是一个“ValueProxy”。
问题:B
列表是在我查询A
时实际查询并下载到客户端的,还是仅在我调用getB()
时才查询并下载到客户端?
Say I have a database, with types A
and B
. A
is an EntityProxy
which contains a list of B
, and B
is a ValueProxy
. I useGWT's RequestFactory to query A
by id. When I query for an A
using RequestFactory, I can access the list of B
like so: A.getB()
, since B
is a `ValueProxy'.
Question: is the B
list actually queried and downloaded to the client at the time I query for A
, or only when I call getB()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有延迟加载:如果您只请求 A,那么您请求“A with Bs”,就会得到“A with Bs”(因为您不使用
.with("b")
在您的请求
中),您只会得到 A,稍后您必须请求 B。将其视为最少意外原则。
请注意,从数据库中获取 B(您用 Hibernate、JPA 和 ORM 标记了问题,所以...)是另一回事。这取决于您如何管理 EntityManager 会话和 JPA 实体的生命周期。很有可能 B 是从数据库加载的,即使它们没有发送到客户端。
There's no lazy-loading: you ask for "A with Bs", you get "A with Bs", if you ask only for A (because you don't use
.with("b")
on yourRequest
), you'll get only A, and you'll have to ask for Bs later.See it as the principle of least surprise.
Note that getting the Bs from your database (you tagged the question with Hibernate, JPA and ORM, so...) is a different story. It depends how you manage your EntityManager session and JPA entities' lifecycle. It might very well be the case that the Bs are loaded from the database even though they're not being sent to the client.