Considerations for Hibernate optimistic lock Timestamp

Source: Internet
Author: User
Lt; timestampnameupdDatecolumnUPD_DATEgt; lt; timestampgt; the time for using the AP server after the id is defined, instead

Lt; timestamp name = updDate column = UPD_DATEgt; lt;/timestampgt; the time for using the AP server after the id is defined, instead

This must be after the id Definition

This uses the Time of the AP server instead of the time of the DB server to update the database.

That is, when updating the database, new Date () is used instead of sysdate.

If you want to use the DB server time to update the database, you must add source = "DB"

At this time, hibernate will first extract the current time (select sysdate from dual) from the database, and then use this time for updates.

Instead of using sysdate to update the database strictly (update table1 set upd_date = sysdate ......).

If the UPDATE results do not contain millisecond information, check Dialect and use org. hibernate. dialect. Oracle10gDialect. (Oracle9 and later versions should support milliseconds)

Do not use org. hibernate. dialect. OracleDialect. This class has been Deprecated.

After org. hibernate. dialect. Oracle10gDialect is used, the SQL statement for obtaining the DB Time will change to select policimestamp from dual.

Hibernate Chinese manual PDF

Hibernate details: click here
Hibernate: click here

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.