Hibernate Hibernate ing between Java time and date types

Source: Internet
Author: User

Basic knowledge:

In Java, the types that represent time and date include: java. util. date and java. util. calendar. in addition, three java extensions are provided in the jdbc api. util. subclass of the Date class: java. SQL. date, java. SQL. time and java. SQL. timestamp, which corresponds to the DATE, TIME, and TIMESTAMP types in the standard SQL type respectively.

In standard SQL, the DATE type indicates the DATE, the TIME type indicates the TIME, and the TIMESTAMP type indicates the TIME stamp. It also contains the DATE and TIME information.




How to map? 1. because java. util. date is java. SQL. date, java. SQL. time and java. SQL. timestamp parent class, so java. util. date can correspond to DATE, TIME, and TIMESTAMP2. of the standard SQL type based on 1, so it is set to java when setting the Date type of persistence class. util. date, because this type can correspond to three Date types in hibernate. how to Set java. util. date is mapped to DATE, TIME, and TIMESTAMP?
Can I use prZ labels? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> frequency =" date "type =" time ">












Use Hibernate built-in ing type

The Hibernate ing type must be explicitly specified in the following cases

A Java type may correspond to multiple Hibernate ing types. for example, if the persistence class property is java. util. date type. The corresponding Hibernate ing type can be date, time, or timestamp. in this case, the Hibernate ing type must be determined based on the SQL type of the corresponding data table field. if the field is of the DATE type, the Hibernate ing type is date. If the field is of the TIME type, the Hibernate ing type is time. If the field is of the TIMESTATMP type, the Hibernate ing type is timestamp.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.