在GWT中序列化JDBC类型 [英] Serializing JDBC Types in GWT

查看:88
本文介绍了在GWT中序列化JDBC类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 GWT 中序列化uknown类型的对象(只有 JDBC 类型)。我有一个持有不知名的jdbc对象列表的对象,我需要它从客户端传输到服务器并返回。如果这个对象序列化为不在gwt客户端环境中,我可以在 Object 列表中保存这些未知对象。但GWT不能序列化 Object 类型的对象。我怎样才能做到这一点?任何建议

解决方案

如果这些jdbc类型没有被任何其他RPC方法返回,那么您可能会遇到问题。 / p>

例如,如果您的Foo类不是通过RPC以除了返回List [Object]之外的任何方法发送的,那么GWT在编译时没有任何知识当它生成RPC白名单时)Foo是一个它应该生成序列化代码的类。这对于生成的JavaScript尤其有意义,避免未使用类型的代码膨胀是非常重要的。



您可以通过手动添加您的未引用类来解决此问题(所有可能的返回来自JDBC的类型)放在通过RPC发送的虚拟类中。
如何添加类型到GWT的序列化政策白名单?

或者,您可以编写自定义的RemoteService生成器来使用,其中添加了不需要Dummy类的类型。
http://code.google.com/webtoolkit/ doc / latest / DevGuideCodingBasicsDeferred.html#generator

I need to serialize object of uknown type(only JDBC types) in GWT. I have an object that holds list of uknown "jdbc" objects and i need it to be transfered from client to server and back. If this object is serializing to file not in gwt client environment I can hold those uknown objects in list of Object's. But GWT can't serialize objects of type Object. How can I achieve this? Any suggestions

解决方案

You may be running into problems if those jdbc types are not being returned by any of your other RPC methods.

If, for instance, your class Foo isn't sent via RPC by any method other than one which returns List[Object], then GWT has no knowledge at compile time (when it generates the RPC whitelist) that Foo is a class that it should generate the code to serialize. This especially makes sense for the generated JavaScript, where avoiding code bloat from unused types is important.

You can work around this by manually adding your otherwise unreferenced classes (all possible return types from JDBC) in a dummy class that gets sent across RPC. How do I add a type to GWT's Serialization Policy whitelist?

Alternately you can write a custom RemoteService generator to use which adds the types without a Dummy class being required. http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsDeferred.html#generator

这篇关于在GWT中序列化JDBC类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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