stableId 的稳定性如何?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
EntityProxyId
对象具有全局范围,适合长期用作Map
键或Set
成员。EntityProxyId
对象可以在RequestFactory
的不同实例和类型之间使用(假设可以从相关的RequestFactory
访问代理类型)。RequestFactory.getHistoryToken()
和getProxyId
方法可以创建适合客户端持久性的EntityProxyId
的字符串表示形式。EntityProxyId
全局范围的一个例外是新创建的EntityProxy
的 ID,该 ID 尚未保留在服务器上。 “临时”id 只能与从中派生新创建的代理对象的RequestFactory
一起使用。一旦代理被发送到服务器并且服务器提供了非空 ID,临时 ID 就会升级为持久 ID,并且与任何其他持久 ID 无法区分。升级后的EntityProxyId
的对象标识不会改变,因此可以将临时 ID 添加到Map
或Set
中并在以后检索。The
EntityProxyId
object has a global scope and is suitable for long-term use as aMap
key or member of aSet
.EntityProxyId
objects can be used across different instances and types of aRequestFactory
(assuming that the proxy type is reachable from theRequestFactory
in question). TheRequestFactory.getHistoryToken()
andgetProxyId
methods can create a string representation of anEntityProxyId
that is suitable for client-side persistence.The one exception to the global scope of an
EntityProxyId
is the id of a newly-createdEntityProxy
that has not yet been persisted on the server. An "ephemeral" id is only usable with theRequestFactory
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 upgradedEntityProxyId
does not change, so ephemeral ids can be added toMap
orSet
and be retrieved later.