30 April 2008 12:45

Hibernate Spring GWT working together!

Kornel Kiełczewski

Case study: you have a beautiful GWT interface and want to connect it somehow to server side code running inside a Spring container to upload and download files from/to a database, additionally protect it using ACEGI.

More generally: Integrate client side GWT Java code with server side Spring code, featuring Hibernate and ACEGI. It is worth considering the Hibernate4GWT project because of the Hibernate-GWT issues, but I will stick to Hibernate and solve these issues using simple DTOs. There is no particular reason I have chosen this method, maybe except the fact, that using DTOs I can easily decide what part of my server-side objects should be send to the GWT interface.

I will show how to create the previously described application step by step, some background knowledge about GWT, Spring, and Hibernate will be very helpful, but I am providing full source hence you might also just copy the code and see how it works.

The interface is heavily based on the Kitchen Sink example from Google - I have slightly changed the CSS and some class names but apart from that almost everything is the same (the idea at least), the server, as previously mentioned, will run with the help of Spring and persist objects in a PostgreSQL database using Hibernate.

The tools and libraries I am using:

To sum up, the application I will show step by step how to develop will eventually feature:

It is quite a broad topic (not very difficult one, however) hence I will divide this article into several chapters:

Let's start or just download the ready application and see yourself:

Download the Complete project without libraries (~300KB) or the Complete project with libraries (~20MB)