hibernate4gwt
http://hibernate4gwt.sourceforge.net
hosted by
SourceForge.net Logo
| Home | News | Getting started | Overview | Hibernate-GWT issues | FAQ | Thanks |

The Hibernate-GWT type issue

Note : this issue is now solved by GWT 1.5 and only concerns previous releases.

The problem

Hibernate replaces some basic Java types with various subclassed implementation  :

  • java.util.Date can be replaced with java.sql.Date or java.sql.Timestamp
  • List is implemented by Hibernate's PersistentList
  • Set  is implemented by Hibernate's PersistentSet

Nevertheless, Javascript serialization of these classes fails, since they do not belong to the JRE emulation supported by GWT.

The easiest way to solve this issue if to convert back the Hibernate types to the JRE ones. 

Dozer and BeanLib do it well (hibernate4gwt too, since it uses BeanLib :) )... except for java.sql.Timestamp !

Timestamp case

As specified in the associated JavaDoc :

"Note: This type is a composite of a java.util.Date and a separate nanoseconds value[...]

Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance."

The fact is that Hibernate does consider Timestamp as a type inheritance of Date, but GWT don't.

Hopefully, since release 0.5, hibernate4gwt supports native java.sql.Timestamp both for clone and merge and adds JSNI port of this class (and java.sql.Date too), so usage of Timestamp is not an issue anymore.


Copyright 2007. All Rights Reserved
 Last updated : 1 June, 2007