stableId 的稳定性如何?

发布于 2024-11-17 18:55:35 字数 293 浏览 2 评论 0原文

EntityProxy.stableId() 的 JavaDoc 说:

"An id returned by a proxy newly created by RequestContext.create 
Object.equals(Object) those returned later by proxies to the persisted object."

这是否意味着稳定 id 在不同的请求上下文中对该对象有效?跨不同的请求工厂实例?我想我想问稳定ID的范围是什么?

The JavaDoc for EntityProxy.stableId() says:

"An id returned by a proxy newly created by RequestContext.create 
Object.equals(Object) those returned later by proxies to the persisted object."

Does that mean that the stable id will be valid for that object across different request contexts? across different request factory instances? I suppose I'm asking what is the scope of the stable id?

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

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

发布评论

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

评论(1

〃温暖了心ぐ 2024-11-24 18:55:35

EntityProxyId 对象具有全局范围,适合长期用作 Map 键或 Set 成员。 EntityProxyId 对象可以在 RequestFactory 的不同实例和类型之间使用(假设可以从相关的 RequestFactory 访问代理类型)。 RequestFactory.getHistoryToken()getProxyId 方法可以创建适合客户端持久性的 EntityProxyId 的字符串表示形式。

EntityProxyId 全局范围的一个例外是新创建的 EntityProxy 的 ID,该 ID 尚未保留在服务器上。 “临时”id 只能与从中派生新创建的代理对象的 RequestFactory 一起使用。一旦代理被发送到服务器并且服务器提供了非空 ID,临时 ID 就会升级为持久 ID,并且与任何其他持久 ID 无法区分。升级后的 EntityProxyId 的对象标识不会改变,因此可以将临时 ID 添加到 MapSet 中并在以后检索。

The EntityProxyId object has a global scope and is suitable for long-term use as a Map key or member of a Set. EntityProxyId objects can be used across different instances and types of a RequestFactory (assuming that the proxy type is reachable from the RequestFactory in question). The RequestFactory.getHistoryToken() and getProxyId methods can create a string representation of an EntityProxyId that is suitable for client-side persistence.

The one exception to the global scope of an EntityProxyId is the id of a newly-created EntityProxy that has not yet been persisted on the server. An "ephemeral" id is only usable with the RequestFactory from which the newly-created proxy object is derived. Once the proxy has been sent to the server and the server has provided a non-null id, the ephemeral id is upgraded to a persistent id and becomes indistinguishable from any other persistent id. The object identity of the upgraded EntityProxyId does not change, so ephemeral ids can be added to Map or Set and be retrieved later.

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