openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Hardy (JIRA)" <>
Subject [jira] Created: (OPENJPA-971) Time handling in Dates
Date Tue, 10 Mar 2009 17:32:50 GMT
Time handling in Dates

                 Key: OPENJPA-971
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 1.2.0
         Environment: Linux
Java 1.6.0_12
MySQL, Hypersonic
            Reporter: Adam Hardy

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

With MySQL it 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. However the MySQLDictionary
refuses to read in Times in the HH:MM:SS format when zero 00:00:00 - it causes the following

<openjpa-1.2.0-r422266:683325 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
Cannot convert value '00:00:00' from column 9 to TIMESTAMP.
	at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(
	at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(
	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(
	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(
	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(
	at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(
	at org.apache.openjpa.kernel.ROPStoreManager.initialize(
	at org.apache.openjpa.kernel.BrokerImpl.initialize(
	at org.apache.openjpa.kernel.BrokerImpl.find(
	at org.apache.openjpa.kernel.BrokerImpl.find(
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(
	at org.apache.openjpa.jdbc.sql.AbstractResult.load(
	at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(
	at org.apache.openjpa.jdbc.sql.AbstractResult.load(
	at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(
	at org.apache.openjpa.kernel.QueryImpl.singleResult(
	at org.apache.openjpa.kernel.QueryImpl.toResult(
	at org.apache.openjpa.kernel.QueryImpl.execute(
	at org.apache.openjpa.kernel.QueryImpl.execute(
	at org.apache.openjpa.kernel.QueryImpl.execute(
	at org.apache.openjpa.kernel.DelegatingQuery.execute(
	at org.apache.openjpa.persistence.QueryImpl.execute(
	at org.apache.openjpa.persistence.QueryImpl.getSingleResult(

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message