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

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
主站蜘蛛池模板: 晋中市| 南郑县| 康马县| 浮梁县| 齐河县| 汾西县| 黄平县| 且末县| 玛沁县| 郧西县| 武山县| 乡城县| 漳州市| 松滋市| 寿光市| 吉隆县| 信宜市| 水富县| 南乐县| 云南省| 荔浦县| 班玛县| 霞浦县| 保德县| 望奎县| 武隆县| 乐都县| 读书| 伊宁县| 临颍县| 吉木乃县| 运城市| 奇台县| 通州区| 科尔| 蒲江县| 汝州市| 沧州市| 咸阳市| 永顺县| 香港 |