Use of Hibernate @Temporal

Source: Internet
Author: User

I recently studied hibernate annotations, but when I used the @temporal annotation, I initially assumed that the value of the property would be automatically assigned after the label was used. It is not necessary to assign a value to the property when inserting the data, which is not the case through repeated research.

The role of @Temporal tags is simple:

(1) If there is a date type attribute in a class, the database store may be ' yyyy-mm-dd hh:MM:ss ' to get the month and year date at the time of the query, and the label @temporal (temporaltype.date) on that attribute will get a shape like ' Date in YYYY-MM-DD ' format.

(2) If there is a date type attribute in a class, the storage in the database may be ' yyyy-mm-dd hh:MM:ss ' to obtain seconds and minutes, and the label on the attribute @Temporal (temporaltype.time) will get the shape as ' HH:MM:SS ' The date of the format.

(3) If there is a date type attribute in a class, the database store may be ' yyyy-mm-dd hh:MM:ss ' to obtain ' is ' yyyy-mm-dd hh:MM:ss ', on which the attribute is labeled @Temporal ( Temporaltype.timestamp) will get a date shaped like ' HH:MM:SS ' format

Use of Hibernate @Temporal

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.