1

I noticed that when I invoke

    SomeProxy proxyNew = someRequestContext.edit(proxyOld);
    proxyNew.setSomething(somethingNew);
    someRequestContext.mySaveMethod(proxyNew).fire();

The entity returned from

    @Override //from Locator<SomeEntity ,IdClass>
    public SomeEntity find(Class<? extends SomeProxy > clazz, IdClass id) {
    ...
    }

is used in server when saving method is invoked and only those property/istance variable values of proxyNew are transfered to server implementation mySaveMethod(SomeEntity entity)which are new in comparison with the returned entity.

Now. I understand that there is some comparison in order to provide server side only with deltas so there is efficiency in communication but I think it is somehow offset by additional processing/transfer time needed by implementation of public SomeEntity find(Class<? extends SomeProxy > clazz, IdClass id) which retrieves the entity objects from database.

My question now is, how should this be correctly implemented in system with persistence services exposed via stateless session bean which provide services to GWT server side servlets/DAO objects. Correctly implemented in a way that the highest efficiency and lowest waiting time is achieved. Also could someone explain to me this RequestFactory aspect/process in greater detail?

My example: I retrieve OrganizerEntry entities from persistence layer for a certain day span - a week.

So the method like retrieveOrganizerEntries(Date from, Date to) is invoked in persistence layer.

Then I see that for each OrganizerEntry entity object obtained which is to be sent to the client layer, another query is made, like retrieveOrganizerEntry(int id).

So not only are the same objects queried twice, but the second time they are queried one by one in a very inefficient manner.

How can this be improved? Should I cache in DAO/servlet objects somehow the results from first query and let public SomeEntity find(Class<? extends SomeProxy > clazz, IdClass id) search the cache? Is it way to go to implement this method returning null or newly created empty entity (new OrganizerEntity()) and before invoking the persist/save method from the client just setting every single property/instance variable value?

Where can I find more examples and explanation about this stuff? Because http://www.gwtproject.org/doc/latest/DevGuideRequestFactory.html seems to me not very exhausting .

4

1 回答 1

1

1.) 关于rf内部,你可以参考这个文档。但我想 Thomas Broyer 会更详细地回应这个问题。

基本流程如下:

  • 通过 setter 修改的属性将传输到服务器。
  • 服务器用于find()检索实体并调用相应的实体setters(无论您在客户端上调用什么)。
  • 处理验证规则
  • 该实体被传递给您的服务方法。

2.)RF你需要one session per http request又名OpenSessioninview 模式。. 您的持久层(即 Hibernate)的第一级缓存应该进行多次冗余调用以find()真正高效,因此您通常只会在会话的生命周期内访问数据库一次。

3.)如果您不关心EntityProxyChange客户端上的事件,您可以覆盖您的isLive()方法Locator并返回true(有关更多详细信息,请参见此处)。find()这也可能是当您检索实例列表时调用该方法的原因,OrganizerEntry因为每个实例都OrganizerEntry RF通过调用本身调用的 'isLive()' 检查它是否仍然存在find()

于 2013-08-07T15:44:53.163 回答