We had a similar problem. Any record with a version between 2 am through 8 am on the date daylight savings turns on or off (>2007 DST or <2007 DST) would not be able to be updated since the update statement would include a version timestamp that was an hour off. We got a StaleObjectException.
We had the issue with JVM versions 1.3.1_07 and 1.4.2_12. We use the Opta MSSQL driver, and the standard DB2 driver.
We use Hibernate 2.1, MSSQL 2000 sp4 and DB2 UDB 7.2. DB2 did not have this issue, only MSSQL. Apparently this is because MSSQL doesn't store timezone information with timestamp types in the database.
As a solution, we wrote our own extension to the hibernate timestamp type. It explicitly sets the timezone when retrieving the date from the database. This fixes the problem mentioned above for MSSQL, and has no adverse affects on DB2 either. We replaced "timestamp" in our hbm.xml file(s) with com.mvsc.persistence.TZTimestamp and the problem was solved.
Hope this is helpful to someone out there!
Jenica
jenica -at- mvsc.com
Code:
public class TZTimestamp extends net.sf.hibernate.type.TimestampType {
public static GregorianCalendar DEFAULT_CALENDAR = new GregorianCalendar();
public Object get(ResultSet rs, String name) throws SQLException {
return rs.getTimestamp(name, DEFAULT_CALENDAR);
}
}