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

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
主站蜘蛛池模板: 南投县| 郓城县| 五寨县| 庆城县| 元朗区| 清徐县| 林甸县| 禹州市| 灵璧县| 上虞市| 当涂县| 高碑店市| 上虞市| 盐边县| 怀集县| 安庆市| 阜南县| 乐东| 遵化市| 西贡区| 淮阳县| 榆社县| 常宁市| 玉龙| 左权县| 天等县| 平泉县| 石泉县| 桦甸市| 榆树市| 吉水县| 鹤壁市| 峨眉山市| 介休市| 尤溪县| 麻栗坡县| 仙游县| 搜索| 瑞安市| 吴堡县| 红桥区|