简体   繁体   English

Spring MVC Hibernate锁表行

[英]spring mvc hibernate lock row of table

Is there any way to lock user edit row when other user editing this row. 当其他用户编辑该行时,有什么方法可以锁定该用户编辑行。 I used spring mvc, hibernate and mysql database. 我使用了spring mvc,hibernate和mysql数据库。 Please help me. 请帮我。 Thanks 谢谢

http://docs.jboss.org/hibernate/core/4.0/devguide/en-US/html/ch05.html https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Web_Platform/5/html/Hibernate_Core_Reference_Guide/transactions-locking.html http://docs.jboss.org/hibernate/core/4.0/devguide/zh-CN/html/ch05.html https://access.redhat.com/site/documentation/zh-CN/JBoss_Enterprise_Web_Platform/5/html /Hibernate_Core_Reference_Guide/transactions-locking.html

Read these links which illustrate how to lock in hibernate. 阅读这些说明如何锁定休眠的链接。

I would recommend a pessimistic one (select for update based) 我会推荐一个悲观的(选择基于更新)

quote: "If Session.load() is called with UPGRADE or UPGRADE_NOWAIT, and the requested object was not yet loaded by the session, the object is loaded using SELECT ... FOR UPDATE. If load() is called for an object that is already loaded with a less restrictive lock than the one requested, Hibernate calls lock() for that object." quote:“如果使用UPGRADE或UPGRADE_NOWAIT调用Session.load(),并且会话尚未加载所请求的对象,则使用SELECT ... FOR UPDATE加载该对象。如果对于已被加载了比请求的限制更少的锁定,Hibernate对该对象调用lock()。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM