由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 请问hibernate这个功能如何实现?
相关主题
How to disable hibernate second-level cache for an entityAbout Hibernate
find all tables used in a hibernate/jdbc project?搞不懂为什么hibernate为什么这么流行?
Apply lock on a class.Struts基本思路请教
Hibernate queryhibernate一个国际化保存unicode value的问题
Talk a little more about How to lock a file再问一个OR Mapping的问题
请教一个多线程lock机制的问题hibernate和ejb3
Java concurrency的疑惑,难道我理解错了? (转载)Hibernate question
同一个Lock锁两次,性能比较差JDBC
相关话题的讨论汇总
话题: hibernate话题: obj话题: entity话题: table话题: version
进入Java版参与讨论
1 (共1页)
l********0
发帖数: 283
1
就是从数据库去取出某个值,这个值加1,然后保存回去
常规方法可以不行,因为多个线程操作的话,有同步问题
谢谢。
b******y
发帖数: 1684
2
I am not familiar with Hibernate, but in row JDBC,
we use a 'version' field to prevent concurrent update.
I would imagine Hibernate would support you do that.

【在 l********0 的大作中提到】
: 就是从数据库去取出某个值,这个值加1,然后保存回去
: 常规方法可以不行,因为多个线程操作的话,有同步问题
: 谢谢。

l********0
发帖数: 283
3
谢谢。
能否具体说说在jdbc中如何实现这个同步问题?

【在 b******y 的大作中提到】
: I am not familiar with Hibernate, but in row JDBC,
: we use a 'version' field to prevent concurrent update.
: I would imagine Hibernate would support you do that.

b******y
发帖数: 1684
4
obj = select * from OBJ_TABLE;
update OBJ_TABLE set name=obj.name, version = version +1
where id=1001 and version=obj.version
only 1 update will succeed.

【在 l********0 的大作中提到】
: 谢谢。
: 能否具体说说在jdbc中如何实现这个同步问题?

t*******e
发帖数: 684
5
Same steps in Hibernate, using versioning for optimistic locking, get the
entity object by HQL or JPQL, incrementing the field of the entity by 1. The
beauty of Hibernate is here, you don't have to call save or update, as the
entity is in persistent state, Hibernate automatically does dirty check and
synchronize the new value with the row in the db table.
l********0
发帖数: 283
6
Thanks a lot.

the
The
the
and

【在 t*******e 的大作中提到】
: Same steps in Hibernate, using versioning for optimistic locking, get the
: entity object by HQL or JPQL, incrementing the field of the entity by 1. The
: beauty of Hibernate is here, you don't have to call save or update, as the
: entity is in persistent state, Hibernate automatically does dirty check and
: synchronize the new value with the row in the db table.

1 (共1页)
进入Java版参与讨论
相关主题
JDBCTalk a little more about How to lock a file
Design question --- hibernate请教一个多线程lock机制的问题
jdbc + oracle connection pooling问题Java concurrency的疑惑,难道我理解错了? (转载)
[求助]实在不明白transaction,ejb这些概念同一个Lock锁两次,性能比较差
How to disable hibernate second-level cache for an entityAbout Hibernate
find all tables used in a hibernate/jdbc project?搞不懂为什么hibernate为什么这么流行?
Apply lock on a class.Struts基本思路请教
Hibernate queryhibernate一个国际化保存unicode value的问题
相关话题的讨论汇总
话题: hibernate话题: obj话题: entity话题: table话题: version