官术网_书友最值得收藏!

Date and time mapping

In a typical relational database, there are three basic data types for columns:

  • Date
  • Time
  • Timestamp

All of these three data types are represented in Java as an instance of the java.util.Date class. To make this clear for mapping by the persistence provider, the @Termporal annotation should be used to identify which one of the three database types should be selected. The following example shows how the @Temportal annotation is used:

@Entity 
public class Movie { 
    @Temporal(TemporalType.DATE) 
    private Date releaseDate; 
} 

The following values are available for the @Termporal annotation:

  • TemporalType.DATE: Date-only values
  • TemporalType.TIME: Time-only values
  • TemporalType.TIMESTAMP: Date with time values
主站蜘蛛池模板: 罗甸县| 南宫市| 南涧| 突泉县| 陆丰市| 班玛县| 科尔| 鹤峰县| 客服| 左权县| 邵东县| 沅江市| 冕宁县| 福海县| 金平| 平武县| 山东省| 彭州市| 会泽县| 比如县| 城市| 拉萨市| 忻城县| 兴国县| 通山县| 清徐县| 和政县| 黎城县| 阳春市| 井陉县| 福清市| 宁化县| 赤壁市| 桐梓县| 德庆县| 渑池县| 威宁| 芦溪县| 灵璧县| 冷水江市| 大邑县|