openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dirk Brenckmann" <>
Subject Q: Howto set TIMESTAMP column to null?
Date Wed, 02 Jul 2008 13:42:07 GMT
Database: mysql 4.1
Geronimo  2.0.1

Hi there,

I'm using a database with timestamp columns that can be null. Using SQL syntax, null enties
can be set by either not setting the field when creating a row, or by explictly setting it
to '0000-00-00 00:00:00'.

This lead me to some amazing discoveries :-)

Merging the Bean using a null value results in a database column value equals to "NOW()" (GNARF!)
java.sql.Timestamp.valueOf( "0000-00-00 00:00:00" ); results in an OutOfMemoryException

--- code ---

     *  Returns the "valid to" timestamp, which specifies the date/time when entitys 
     *  data becomes invalid. A value of null or '0000-00-00 00:00:00' means, the entity
     *  never becomes invalid.
     *  @return the "valid to" timestamp of the entity.
    @Column( name = "validTo",
             columnDefinition = "timestamp default '0000-00-00 00:00:00'",
             nullable = true, insertable = true, updatable = true )
    // @Temporal( TemporalType.TIMESTAMP ) 
    public java.sql.Timestamp getValidTo() {
        return this.validTo;
--- code ---

Switching to java.langString (as return type) results in an OutOfMemoryException (My guess
is a convertion: see Timestamp)

The @Temporal annotation was removed, due to what ? You are right - due to an OutOfMemoryException

Please be aware that changing the database (a few GB data) to not use null/'0000-00-00 00:00:00'
values is no option at all.

Any ideas how to get this working?
Tyvm in advance.
GMX startet Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein:

View raw message