Javers - What are advantages of using Javers instead of Envers?

淺唱寂寞╮ 提交于 2019-12-06 11:21:45

There are two big difference between JaVers and Envers:

  1. Envers is the Hibernate plugin. It has good integration with Hibernate but you can use it only with traditional SQL databases. If you choosed NoSQL database or SQL but with other persistence framework like JOOQ — Envers is not an option.

    On the contrary, JaVers can be used with any kind of database and any kind of persistence framework. For now, JaVers comes with repository implementations for MongoDB and popular SQL databases. Other databases (like Cassandra, Elastic) might be added in the future.

  2. Envers’ audit data model is a copy of application’s data model. As the doc says: For each audited entity, an audit table is created. By default, the audit table name is created by adding a _AUD suffix to the original name. It can be advantage, you have audit data close to your live data. Envers’ tables look familiar. It’s easy to query them with SQL.

    JaVers uses its own Snapshot model for audit data. Snapshots are decoupled from live data, JaVers saves them to the single table (jv_snapshots) as JSON documents with unified structure. Advantages? You can choose where to store audit data. By default JaVers uses the same database as application does, but you can point another database. For example, SQL for application and MongoDB for JaVers or centralized JaVers database shared for all applications in your company).

Read this blogpost with full JaVers vs Envers comparison: https://javers.org/blog/2017/12/javers-vs-envers-comparision.html

Peter Rader

Enver is like git for a database.

I do not know Javers but a complete Envers databinding has this advantages:

  1. A table is created in the database called REVINFO having a timestamp and a PK.
  2. To every entity that is audited, one shadow-copy is created. Theese shadow-copies have every field nullable and the PK is not a PK. Theese shadow-copies have a new field, the reference to the table REVINFO.

This gives Enver the possibility to record changes that has been made in the past in this shadow-copies. You can move that shadow-tables into an different database.

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