Absence of @Temporal annotation in hibernate

前端 未结 2 1496
小鲜肉
小鲜肉 2021-02-05 03:40

What if we use

@Column(name=\"birth_date\", nullable=false, length=19)
public Date getBirthDate() {
    return this.birthDate;
}

instead of

2条回答
  •  没有蜡笔的小新
    2021-02-05 04:18

    Only piece of documentation I managed to find:

    In plain Java APIs, the temporal precision of time is not defined. When dealing with temporal data you might want to describe the expected precision in database. Temporal data can have DATE, TIME, or TIMESTAMP precision (ie the actual date, only the time, or both). Use the @Temporal annotation to fine tune that.

    From 2.2.2.1. Declaring basic property mappings.

    This might indicate that the actual date representation in the database is not defined and to be sure it is better to specify it directly.

提交回复
热议问题