0

I'm using:

Eclipselink 2.5.0
HSQLDB 2.3
JPA 2.1
Spring 4.0.5

I have this entity:

@Entity
public class MyEntity {

    ...

    @Temporal(TemporalType.DATE)
    @Convert(converter = MyLocalDateTimeConverter.class)
    private LocalDate date;

}

When the HSQLDB/Eclipselink generate the DDL, it generates the dabase field as:

TIMESTAMP

When I access (via select) this entity, my converter get a java.sql.Timestamp instead of java.sql.Date and converts the value to a LocalDateTime instead of LocalDate.

How can I force to generate the field as:

DATE // respecting the Temporal definition
Beto Neto
  • 3,962
  • 7
  • 47
  • 81
  • I found a workaround, by definition the @Column(columnDefinition = "DATE"), but I need to fix this without using SQL. – Beto Neto Jun 03 '14 at 16:41

1 Answers1

-1

The reason you are getting a java.sql.TimeStamp is very easy, you have not only year, month and day in the DB, but also hour, minute and second perhaps.

The only difference between java.sql.Date and java.sql.Timestamp is Timestamp carries more information like hour,..

..., which means, it is correct for you to get a java.sql.Timestamp.

PS: java.sql.Date and java.sql.Timestamp are both wrapper of java.util.Date..

Jaiwo99
  • 9,687
  • 3
  • 36
  • 53
  • I known the difference between Timestamp and Date, the fact is that I want/need to use Date type (year, month, day only) in database, and I need to generate the DDL with DATE and not TIMESTAMP. – Beto Neto Jun 03 '14 at 16:34