Should I build a REST backend for GWT application

前端 未结 7 562
悲哀的现实
悲哀的现实 2020-12-23 20:30

I am planning a new application and have been experimenting with GWT as a possible frontend. The design question I am facing is this.

Should I use Option A: GWT-RPC

7条回答
  •  醉话见心
    2020-12-23 21:16

    If you're planning on using using Hibernate/JPA on the server-side and sending the resulting POJO's with relational data in them to the client (ie. an Employee object with a collection of Phones), definitely go with the REST implementation.

    I started my GWT project a month ago using GWT RPC. All was well until I tried to serialize an object from the underlying db with a One-To-Many relationship in it. And got the dreaded:

    com.google.gwt.user.client.rpc.SerializationException: Type 'org.hibernate.collection.PersistentList' was not included in the set of types which can be serialized by this SerializationPolicy
    

    If you encounter this and want to stay with GWT RPC you will have to use something like:

    • GWT Request Factory (www.gwtproject.org/doc/latest/DevGuideRequestFactory.html) - which forces you to write 3+ classes/interfaces per POJO you want to share with the client. OUCH!
    • Gilead (sourceforge.net/projects/gilead/) - which appears to a dead project.

    I'm now using RestyGWT. The switch was fairly painless and my POJO's serialize without issue.

提交回复
热议问题