How can I map a Java date to DATETIME in mysql (by default its TIMESTAMP) with Hibernate annotations

Use the columnDefinition attribute of the @Column annotation:

@Column(name = "startTime", columnDefinition="DATETIME")
@Temporal(TemporalType.TIMESTAMP)
private Date startTime;

And please, make your attributes private.

Leave a Comment