java - Hibernate PostInsertEventListener.requiresPostCommitHanding 做什么?
问题描述
在文档 [1] 中它说:
这个监听器是否需要在事务挂钩之后注册?
这是否意味着,如果我们返回,监听器将在事务提交之前运行,如果我们返回false
,则在事务提交之后运行true
?
解决方案
似乎,当PostInsertEventListener
注册为时EventType.POST_INSERT
,根本不调用该方法,并且始终在提交事务之前执行侦听器。
但是,如果侦听器注册为EventType.POST_COMMIT_INSERT
实际调用的方法,并且如果它返回true
,则将在提交事务后调用侦听器。如果它返回,则根本不会调用false
侦听器。
此外,如果侦听器是类型,则无论事务是否成功,都会调用PostInsertEventListener
该方法。onPostInsert
如果侦听器是类型的,则只会为成功的事务调用PostCommitInsertEventListener
该方法。onPostInsert
否则,onPostInsertCommitFailed
调用该方法。
推荐阅读
- sql-server - 发布时对象名称无效:SQLPackage (DACFramework 15) 可能的错误
- google-apps-script - Google 脚本:我的基于时间的触发器不起作用
- javascript - 使用 javascript 以动态形式从 php(下拉列表)添加值
- batch-file - 如何计算批处理文件运行的次数?
- python - 在 Pandas Dataframe 上执行 SQL 并将结果存储在同一个 Dataframe 中
- python - 如何让 fontforge 模块打印瀑布样本?
- javascript - 表单提交后显示不在数组中的项目
- c# - 采用 EF 模型并将其转换为数据表?
- javascript - 我们可以从提交表单中发布 getelement.id('').innerhtml 吗?
- c - 使用 sscanf 和括号将字符串分解成小块