openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Renaud <benjamin.ren...@gmail.com>
Subject MappingTool-generated SQL for TIMESTAMP
Date Tue, 21 Dec 2010 23:39:41 GMT
I think I may have uncovered a bug in the way TIMESTAMP fields are generated
by the MappingTool.

I have a field

@Entity
public class MyEntity {

    @Column(name = "due_date")
    @Temporal(value = TemporalType.TIMESTAMP)
    private Date dueDate;

In PostgresSQL, this generates a nullable TIMESTAMP column (with no
default). No problem.

In MySQL, it generates

CREATE TABLE ... ( ..., due_date TIMESTAMP, ...)

In MySQL 5, this is a field that 1. is not nullable and 2. defaults to
CURRENT_TIMESTAMP.

The way to have it behave as a nullable field without a default is to
specify:

CREATE TABLE ... ( ..., due_date TIMESTAMP NULL, ...)

Even if this is not the default behavior (which in my mind it should be, or
the Postgres one should be changed to behave the same way) the following:


    @Column(name = "due_date", nullable = true)
    @Temporal(value = TemporalType.TIMESTAMP)
    private Date dueDate;

Should really generate the NULL constraint.

JPA mavens, what say you?

Thanks!!
Benjamin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message