I am using eclipselink JPA implementation (Entity) with GWT 2.0 framework on presentation layer. Everything is working properly. But when i change my JPA implementation to Hibernate, I get Serialization/Deserialization Exception on GWT Layer when I pass entity beans but It is okay on eclipselink JPA. Whats really happens? Hibernate is an implementation of JPA and eclipselink too, why those act differently?
What should I do for solving this exception on Hibernate? using Hibernate4gwt?
Which JPA implementation is better for GWT?
Regards
Another thought: Custom Field Serializers.
Example: MyClass has a member mapped in a One To Many relationship with YourClass:
The precise implementation Hibernate will use is probably PersistentBag, which is not serializable, for the reasons Pascal mentioned. But GWT provides Custom Field Serializers to control the serialization. It would look something like this.
Advantage here is not having to mess with Gilead/Dozer/more external libraries.
I recommend to read the whole Using GWT with Hibernate paper, it explains very nicely why enhanced classes (whether you're using proxies or weaving) are "problematic" for GWT:
So my understanding it that this isn't an Hibernate specific problem and you might also run into troubles with alternative JPA implementations, including EclipseLink if you use static or dynamic weaving (you're not forced to use weaving but then you miss features like lazy loading or fetch groups).
The paper suggests several integration strategies allowing to workaround the issues:
It also discusses their pros and cons, just check it out.
To sum up...
First, I don't think there is a "best" JPA implementation for GWT, they are all facing the same issue. If you can live without lazy loading, EclipseLink without weaving might be simpler. But you'd be somehow burying your head in the sand, the issue is there and you won't be able to use another implementation.
Second, while the two first "integration strategies" will work with any JPA provider, Hibernate is the only JPA implementation currently supported by Gilead (but OpenJPA and EclipseLink supports is planned).
Pick your poison :)
See also