openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dirk Brenckmann" <Brenckmann.Sourcefo...@gmx.de>
Subject Fwd: Q: Howto set TIMESTAMP column to null?
Date Wed, 02 Jul 2008 13:47:04 GMT
-------- Original-Nachricht --------
Datum: Wed, 02 Jul 2008 15:42:07 +0200
Von: "Dirk Brenckmann" <Brenckmann.Sourceforge@gmx.de>
An: users@openjpa.apache.org
Betreff: Q: Howto set TIMESTAMP column to null?

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 ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

-- 
Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
Der Eine für Alle: http://www.gmx.net/de/go/messenger03

Mime
View raw message