本文介绍了GWT RequestFactory:我如何从stableId()获得一个持久性ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的实体中使用), )方法在RequestContext中。这不会从 EntityProxyId 中检索持久性标识,但它确实为我提供了一个请求中新对象的持久标识。

It finally occurred to me (after tbroyer told me ;)) that I could return the Long id from the persist() method in the RequestContext. This doesn't retrieve the persistent id from the EntityProxyId, but it does get me the persistent id of a new object in a single request.

我打开这个问题 - 我仍然对从EntityProxyId获取持久性id感兴趣。

I'll leave this question open - I am still interested in getting the persistent id out of an EntityProxyId.

推荐答案

实现 EntityProxyId 的类是 SimpleEntityProxyId 。这个类有一个方法 getServerId(),它将返回这个id。因此,通过检查 instanceof ,然后可以调用该方法。 (实际上 RequestFactory.getHistoryToken()甚至没有检查,只是简单地转换为这个类)。

The class implementing an EntityProxyId is SimpleEntityProxyId. This class has a method getServerId(), which will return the id. So by checking with instanceof you can then call the method. (Actually RequestFactory.getHistoryToken() doesn't even check, but simply casts to this class).

现在坏消息是:它是编码的,它的基类是 SimpleEntityProxyId ,它是 SimpleProxyId 并包含方法 getServerId(),明确指出: b
$ b

Now the bad news: it's encoded and the base class for SimpleEntityProxyId, which is SimpleProxyId and contains the method getServerId(), specifically states:

(其中字段 encodedAddress 包含服务器ID。)

(Where the field encodedAddress contains the server id.)

这篇关于GWT RequestFactory:我如何从stableId()获得一个持久性ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 01:09