休眠事件监听器-postFlush等效项 [英] Hibernate event listener - postFlush equivalent

查看:50
本文介绍了休眠事件监听器-postFlush等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用休眠事件侦听器实现简单的审核日志功能.我想累积事务中所有实体的所有更改并处理审计.

I am implementing a simple audit log functionality using hibernate event listeners. I wanted to accumulate all the changes for all entities in a transaction and handle auditing.

通过使用休眠拦截器方法,我们可以使用postFlush()来处理所有累积的审核事件的审核.

By using hibernate interceptors approach we have postFlush() where we handle auditing of all the accumulated audit events.

事件侦听器等效于什么?

What is the equivalent for event listeners?

我尝试使用'hibernate.ejb.event.flush'事件.但是它甚至在onPostInsert,onPostUpdate和onPostDelete事件之前就调用生命周期的最开始.因此无法累积更改.

I tried using 'hibernate.ejb.event.flush' event. But it invokes very beginning of the life cycle, even before onPostInsert, onPostUpdate and onPostDelete events. So cannot accumulate changes.

也尝试过自动冲洗,但是也没有用.有什么主意吗?

Also tried with auto-flush, it also didn't work. Any idea?

推荐答案

只是不要误导其他人,所以我发现冲洗事件侦听器确实有效.问题是默认未注册休眠事件监听器.当我将默认事件侦听器与自定义侦听器一起注册时,它开始正常工作.

Just not to misled others, I figured it out that flush event listener actually works. The problem is default hibernate event listeners are not registered. When I register default event listeners along with custom listener, it started working fine.

这篇关于休眠事件监听器-postFlush等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆