Does HibernateTemplate work with Envers? If so, how?

孤者浪人 提交于 2019-12-06 11:33:24

HibernateTemplate has its JPA counterpart, JpaTemplate which provides a fairly similar functionality.

The reason Envers doesn't work with HibernateTemplate is because it relies on JPA events (you can see the listeners declared in your persistence.xml above) triggered when EntityManager is used. It's possible in theory to write code to trigger those events from Hibernate session when HibernateTemplate is used, but it's rather involved.

All u needed to do was put @Transactional in your Dao or services which call the dao.save()/ update methods.

Even if you register your eventlistener these events are not fired unless you use transcational of the Spring FW. Spring has to know and tell hibernate that these events are fired.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!