通过GWT-RPC发送持久化的JDO实例 [英] Sending persisted JDO instances over GWT-RPC
问题描述
我的想法是否正确:如果您想坚持一段时间业务对象(例如股票)使用JDO并将它发送到/来自客户端通过RPC,然后必须为该对象创建两个单独的类:一个JDO注释用于将它保存在服务器上,另一个可以通过RPC进行序列化和使用?
我注意到Stock Watcher有单独的类,我可以理论化为什么:
- 否则,gwt编译器会尝试
为所有内容生成javascript
引用的持久化类像
JDO和com.google.blah.users.User等 - 在服务器端
类中也可能有逻辑,它不适用于客户端
,反之亦然。
我只是想确保我正确理解这一点。如果我不需要 ,我不想创建我想用于RPC 的所有业务对象类的两个版本。
简短回答是:您不需要创建重复的类。
我建议您从gwt-contributors列表的以下Google小组讨论中看一看:
http://groups.google.com/group/google-web-toolkit-contributors/browse_thread/thread/ 以下是一段有趣的摘录:如果这是你感兴趣的全部内容,那么I ,一切都会正常工作,但是当 您可以使用此选项,并且不需要镜像(DTO)类。 I've just started learning Google Web Toolkit and finished writing the Stock Watcher tutorial app. 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? I notice the Stock Watcher has separate classes and I can theorise why: 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. The short answer is: you don't need to create duplicate classes. I recommend that you take a look from the following google groups discussion on the gwt-contributors list: Here is an interesting excerpt: 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. 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屋!
描述了一种使GAE和
GWT-RPC从
盒子中一起工作的方法。只需将您的实体声明为:
@PersistenceCapable(identityType =
IdentityType.APPLICATION,可分离
=false)public class MyPojo实现Serializable {}
从客户端发送回服务器时,
必须手动处理
重新连接。
您也可以尝试 gilead (以前的hibernate4gwt),它会在序列化增强对象的过程中处理一些细节。