Hibernate中@Temporal的使用

@Temporal标签的作用。

  1. 如果在某类中有Date类型的属性,数据库中存储可能是’yyyy-MM-dd hh:MM:ss’要在查询时获得年月日,在该属性上标注@Temporal(TemporalType.DATE) 会得到形如’yyyy-MM-dd’ 格式的日期。

  2. 如果在某类中有Date类型的属性,数据库中存储可能是’yyyy-MM-dd hh:MM:ss’要获得时分秒,在该属性上标注 @Temporal(TemporalType.TIME) 会得到形如’HH:MM:SS’ 格式的日期。

  3. 如果在某类中有Date类型的属性,数据库中存储可能是’yyyy-MM-dd hh:MM:ss’要获得’是’yyyy-MM-dd hh:MM:ss’,在该属性上标注 @Temporal(TemporalType.TIMESTAMP) 会得到形如’HH:MM:SS’ 格式的日期

Adhere to the original technology to share, your support will encourage me to continue to create!