开发者

How stable is stableId?

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 wha开发者_开发知识库t is the scope of the stable id?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜