通过 GWT-RPC 发送持久化的 JDO 实例 [英] Sending persisted JDO instances over GWT-RPC

查看:25
本文介绍了通过 GWT-RPC 发送持久化的 JDO 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习 Google Web Toolkit,并完成了 Stock Watcher 教程应用的编写.

I've just started learning Google Web Toolkit and finished writing the Stock Watcher tutorial app.

我的想法是否正确,如果想要持久化一个业务对象(比如股票)使用 JDO 并将其发送来回客户端>通过 RPC 那么必须为该对象创建两个单独的类:一个带有 JDO 注释以将其持久化在服务器上,另一个可序列化并通过 RPC 使用?

Is my thinking correct that if one wants to persist a business object (like a Stock) using JDO and send it back and forth to/from the client over RPC then one has to create two separate classes for that object: One with the JDO annotations for persisting it on the server and another which is serialisable and used over RPC?

我注意到 Stock Watcher 有不同的类,我可以推测原因:

I notice the Stock Watcher has separate classes and I can theorise why:

  • 否则 gwt 编译器会尝试为一切生成javascript引用的持久化类JDO 和 com.google.blah.users.User 等
  • 服务器端也可能有逻辑不适用于客户端的类反之亦然.

我只是想确保我理解正确.如果我不需要,我不想创建我想通过 RPC 使用的所有业务对象类的两个版本.

I just want to make sure I'm understanding this correctly. I don't want to have to create two versions of all my business object classes which I want to use over RPC if I don't have to.

推荐答案

简短的回答是:你不需要创建重复的类.

我建议您查看以下关于 gwt-contributors 列表的 google 群组讨论:

I recommend that you take a look from the following google groups discussion on the gwt-contributors list:

http://groups.google.com/group/google-web-toolkit-contributors/browse_thread/thread/3c768d8d33bfb1dc/5a38aa812c0ac52b

这是一个有趣的摘录:

如果这就是你的全部兴趣,我描述了一种制作 GAE 的方法和GWT-RPC 协同工作走出去"框".只需将您的实体声明为:@PersistenceCapable(identityType =IdentityType.APPLICATION,可拆卸= "false") 公共类 MyPojo 实现了 Serializable { }

If this is all you're interested in, I described a way to make GAE and GWT-RPC work together "out of the box". Just declare your entities as: @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "false") public class MyPojo implements Serializable { }

一切都会好起来的,但你会必须手动处理发送对象时重新附加从客户端返回到服务器.

and everything will work, but you'll have to manually deal with re-attachment when sending objects from the client back to the server.

您可以使用此选项,并且不需要镜像 (DTO) 类.你也可以试试 gilead(前 hibernate4gwt),它负责处理序列化增强对象问题中的一些细节.

You can use this option, and you will not need a mirror (DTO) class. You can also try gilead (former hibernate4gwt), which takes care of some details within the problems of serializing enhanced objects.

这篇关于通过 GWT-RPC 发送持久化的 JDO 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆