简体   繁体   English

Hibernate 锁 Object 用于 4 眼检查

[英]Hibernate Lock Object for 4 eye check

I have a database application with objects, that shall only be modified using a 4/6 eyes check.我有一个带有对象的数据库应用程序,只能使用 4/6 眼检查对其进行修改。

For example: I have a "Person" in a database, and the attribute "person_name" (or any other attribute of that object) can only be changed once the change has been reviewed by someone else.例如:我在数据库中有一个“Person”,并且属性“person_name”(或该对象的任何其他属性)只有在其他人审查更改后才能更改。 For that, a new object "Person_modification" is created in the database, that has an attribute "approvement_status" with possible values "approved", "rejected" etc..为此,在数据库中创建了一个新的 object“Person_modification”,它的属性“approvement_status”具有可能的值“批准”、“拒绝”等。

From the moment the new object "Person_modification" has been created, until its either in status "approved" or "rejected", the underlying "Person" object should be locked, ie it must not be modifiable by any other user/transaction.从创建新的 object“Person_modification”的那一刻起,直到其处于“已批准”或“拒绝”状态,底层的“Person” object 应该被锁定,即它不能被任何其他用户/事务修改。 Ie between the initial change and the approval of the change could lie days or weeks/ months.即在初始变更和变更批准之间可能存在数天或数周/数月。 During that time, the object should not be modifiable.在此期间,不应修改 object。

Is there a functionality in Hibernate, that lets me put such a lock on an object that lasts way beyond a "transaction" in a hibernate sense until its manually released? Hibernate 中是否有一个功能,它可以让我在 object 上放置这样的锁,它的持续时间远远超出 hibernate 感知中的“事务”,直到手动释放?

Or would the way to go here to create an additional attribute on the "Person" object that inidicates if its currently being modified by a "Person_modification" object?或者到 go 的方式是在“Person”object 上创建一个附加属性,指示其当前是否被“Person_modification”object 修改?

go with additional attributes instead of hibernate based as they are transactional only. go 具有附加属性,而不是基于 hibernate,因为它们只是事务性的。 you can create triggers which can monitor updates and allow them only when certain conditions are true您可以创建可以监视更新的触发器,并仅在某些条件为真时才允许它们

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

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