Google Web Toolkit (GWT) + Google App Engine (GAE) + Detached Data Persistence

后端 未结 11 2056
旧时难觅i
旧时难觅i 2020-12-23 11:03

I would like to develop a web-app requiring data persistence using GWT and GAE. As I understand it, my only (or at least by far the most convenient) option for data persiste

相关标签:
11条回答
  • 2020-12-23 11:26

    since GWT ultimately compiles to JavaScript, for detached persistence it would need one of a few services available. the best known are HTML5 stores and Gears (both use SQLite!). of course, neither is widely deployed, so you'd have to convince your users to either use a modern browser or install a little-known plugin. be sure to degrade to a usable subset if the user doesn't comply

    0 讨论(0)
  • 2020-12-23 11:28

    Try use http://gilead.sourceforge.net/

    0 讨论(0)
  • 2020-12-23 11:28

    You can consider using JSON. GWT has necessary API to parse & generate JSON string in the client side. You get a lot of JSON API for server side. I tried with google-gson, which is fine. It converts your JSON string to POJO model and viceversa. Hope this helps you providing a decent solution for your requirement

    0 讨论(0)
  • 2020-12-23 11:30

    Ray Cromwell has a temporary hack up. I've tried it, and it works.

    It forces you to use Transient instead of Detachable entities, because GWT can't serialize a hidden Object[] used by DataNucleus; This means that the objects you send to the client can't be inserted back into the datastore, you must retrieve the actual datastore object, and copy all the persistent fields back into it. Ray's method uses reflection to iterate over the methods, retrieve the getBean() and setBean() methods, and apply the entity setBean() with your transient gwt object's getBean().

    You should strive to use JDO, the JPA isn't much more than a wrapper class for now. To use this hack, you must have both getter and setter methods for every persistent field, using PROPER getBean and setBean syntax for every "bean" field. Well, ALMOST PROPER, as it assumes all getters will start with "get", when the default boolean field use is "is".

    I've fixed this issue and posted a comment on Ray's blog, but it's awaiting approval and I'm not sure if he'll post it. Basically, I implemented a @GetterPrefix(prefix=MethodPrefix.IS) annotation in the org.datanucleus package to augment his work.

    In case it doesn't get posted, and this is an issue, email x_AT_aiyx_DOT_info Re: @GetterPrefix for JDO and I'll send you the fix.

    0 讨论(0)
  • 2020-12-23 11:30

    Currently, I use the DTO (DataTransferObject) pattern. Not necessarily as clean and plenty more boilerplate but GAE still requires a fair amount of boilerplate at current. ;)

    I have a Domain Object mapped (usually) one-to-one with a DTO. When a client needs Domain info, a DAO(DataAccessObject) coughs up a DTO representation of the Domain object and sends that across the wire. When a DTO comes back, I hand the DAO the DTO which then updates all the appropriate Domain Objects.

    Not as clean as being able to pass Domain Objects directly across the wire obviously but the limitations of GAE's JDO implementation and GWT's Serialization process means this is the cleanest way for me to handle this currently.

    0 讨论(0)
提交回复
热议问题