英文:
How do I update operation based on logic in perUpdate event
问题
我希望在调用Hibernate的PostUpdateEventListener回调函数onPostUpdate()方法时能够有条件地触发。我正试图通过在Hibernate生命周期回调方法PreUpdateEventListener的onPreUpdate()方法中编写一些逻辑来实现这一点,以便它将检查特定条件并在条件计算为假时停止进一步的更新处理和执行onPostUpdate()方法。
在onPreUpdate方法中返回true或false值是否有任何意义,以停止进一步的更新处理和执行onPostUpdate()方法?我已经尝试过从preUpdate()方法中返回true和false,但没有任何影响,即在两种情况下都会执行更新处理,并调用postUpdate()方法。
详情:这是一个审核员制的要求。我的要求是在数据库中记录一些特定的实体,以标记它们为“已审核”,并记录更新请求的数据,如果用户角色是“制作者”,则只对“审核员”类型的用户进行更新调用。因此,如果用户角色是制作者,我需要阻止更新处理,将它们标记为“已审核”,并通过“审核员”用户角色进行更新。
英文:
I want Hibernate PostUpdateEventListener callback onPostUpdate() method to invoke conditionally. I am trying to achieve this by writing some logic in the hibernate lifecycle callback method onPreUpdate() method of PreUpdateEventListener , so that it will check a specific condition and stop further update processing & execution of onPostUpdate() if the condition evaluates to false.
Is there any significance of returning true or false value from onPreUpdate method to stop further update processing and execution of onPostUpdate() method. I already tried to return true as well as false from preUpdate() but there is no impact i.e. in both cases update processing is being performed & postUpdate() method invocation is being done.
Details : It is checker maker requirement.My requirement is to log some specific set of entities in Database to mark them as checked along with the data of update request if the user role is "Maker" and only do updates call in DB if user is of type "Checker". Therefore I need to prevent update processing if the user role is maker and log them as "Checked" and update through "Checker" user role.
专注分享java语言的经验与见解,让所有开发者获益!
评论