openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <>
Subject Time handling in Dates
Date Mon, 09 Mar 2009 13:25:49 GMT
I have what looks like a bug in time handling, that probably stems from the 
database Dictionaries. My testing shows it occurs with MySQL and Derby, but not 
for PostgreSQL, H2 or Hypersonic (using latest GA versions of Java, OpenJPA & 
JDBC drivers).

If I save an entity with this set-up, I see incorrect handling of dates:

class MyEntity
     private java.util.Date opening;


       <basic name="opening">
         <column name="OPENING"/>


create table MY_ENTITY (
     OPENING time not null,

In my test I assign a new value to 'opening', save the entity and retrieve it 
from the database again. Then I compare the date on the retrieved entity against 
the value originally assigned, and I get this result:

with Derby: original Calendar.HOUR_OF_DAY == 9, retrieved value = 10

(probably due to Daylight Saving Time handling)

with MySQL: original Calendar.YEAR == 1970, retrieved value = 1969

(could be declared irrelevant since the value comes from a Time database type 
and the Java comparisons should blank out or ignore non-time Date values).

I couldn't find this in JIRA but thought I'd bring it up here before logging it. 
I can post a unit test showing the bug. Shall I do that now?


View raw message