Hello Michael,

ty 4 your answer.

> After some experimentation 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.

Sorry, this did not do the trick for me. Maybe because there were
changes in timestamp behaviour between v.4.x and 5.x
I'm currently experimenting with different drivers and will drop a note
when I find something useful/reproduceable.

> What happens if you insert a row through the mysql console?

32187  pu for org.brenckmann.java.ejb.core classes  TRACE
       [Thread-50] openjpa.jdbc.SQL - <t 18504163, conn 28291117>
       executing prepstmnt 28598399
       INSERT INTO fp_tuo.type (version, userid, validFrom, validTo,
       description, shortname, type_id) VALUES (?, ?, ?, ?, ?, ?, ?)
       [params=(BigDecimal) 0, (String) dummy, (Timestamp) 2008-07-02
       21:50:53.015, (null) null, (String) description of 'shortname',
       (String) shortname 1, (BigDecimal) 0]

Copy/Past to the mysql console just does the same like openjpa. It
results in a row with:
  validFrom == validTo == '2008-07-02 21:50:53.015'

1) But: (notice the missing 'validTo' !)
INSERT INTO fp_tuo.type (version, userid, validFrom, description,
       shortname, type_id) VALUES ( 0, "dummy", 2008-07-02
       21:50:53.015, "description of 'shortname'", "shortname 1", 0 )

2) Or: (notice the 'validTo' (datetime) string !)
INSERT INTO fp_tuo.type (version, userid, validFrom, validTo
       description, shortname, type_id) VALUES ( 0, "dummy",
       '2008-07-02 21:50:53.015', '0000-00-00 00:00:00',
       "description of 'shortname'", "shortname 1", 0 )

1) and 2) Both result in rows using:
  validFrom == '2008-07-02 21:50:53.015'
  validTo == 0/'0000-00-00 00:00:00'

It seems like my mysql interprets 'null' like 'now()', 'not available'
like '0/0000-00-00 00:00:00' and '0000-00-00 00:00:00' correctly.
Perhaps this is more like a driver issue?

2) makes me think, there would be a workarround for my problem, if it
was possible to persuade openjpa to convert datetime columns to
java.lang.String instead of java.sql.Timestamp ... e.g.:

       INSERT INTO fp_tuo.type (version, userid, validFrom, validTo,
       description, shortname, type_id) VALUES (?, ?, ?, ?, ?, ?, ?)
       [params=(BigDecimal) 0, (String) dummy, (String) 2008-07-02
       21:50:53.015, (String) 0000-00-00 00:00:00, (String) description
       of 'shortname', (String) shortname 1, (BigDecimal) 0]

> I wasn't able to reproduce the out of memory error with @Temporal.  Could
> you provide the stack for that problem?

Sorry, I currently can't. I guess the error was in my place, because
@Temporal now does not do any trouble. Maybe I had left some code
fragments that did the trouble ... too much testing/code switching :-)

Greetings

Reply via email to