Home > Database > Mysql Tutorial > body text

Hibernate乐观锁之Timestamp注意点

WBOY
Release: 2016-06-07 16:49:12
Original
1055 people have browsed it

lt;timestamp name=updDate column=UPD_DATEgt;lt;/timestampgt; 这个必须跟在id定义之后 这使用AP服务器的时间,而不是

这个必须跟在id定义之后

这使用AP服务器的时间,而不是DB服务器的时间,来更新数据库。

即更新数据库时使用的是new Date(),,而不是sysdate。

如果要使用DB服务器时间来更新DB,必须加上source="db"

此时,hibernate会先从数据库中取出当前时间(select sysdate from dual),然后再用该时间进行更新。

并不是严格意义上的用sysdate更新数据库(update table1 set upd_date=sysdate ……)。

如果更新结果中没有毫秒信息,请检查Dialect,应使用org.hibernate.dialect.Oracle10gDialect。(Oracle9及其后续版本应该都支持毫秒)

不要使用org.hibernate.dialect.OracleDialect,该类已经被Deprecated。

使用org.hibernate.dialect.Oracle10gDialect之后,取DB时间的SQL会变为 select systimestamp from dual。

Hibernate 中文手册 PDF

Hibernate 的详细介绍:请点这里
Hibernate 的下载地址:请点这里

本文永久更新链接地址:

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!