Hi Dirk,
What happens if you insert a row through the mysql console?
I created a table with the column definition you provided and I found that
the column was always set to the current time. After some experimentation I
found that using TIMESTAMP NULL had the desired behavior - ie :
@Column(name = "validTo", columnDefinition = "TIMESTAMP NULL", nullable
= true, insertable = true, updatable = true)
@Temporal(TemporalType.TIMESTAMP)
I tried this with MySQL v5.0.5 - I imagine it would work the same on v4.1
though.
I wasn't able to reproduce the out of memory error with @Temporal. Could
you provide the stack for that problem?
h2h,
-mike
On Wed, Jul 2, 2008 at 8:42 AM, Dirk Brenckmann <
[EMAIL PROTECTED]> wrote:
> 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/[EMAIL PROTECTED]
>