hibernate-envers

Creating Envers custom revision entity

ε祈祈猫儿з 提交于 2019-12-10 04:05:13
问题 I'm trying to setup audit for our project. I started from the default configuration which works fine. The next step is to store the user which has made changes. Following the manual I created custom entity revision: package com.csbi.samples.utils.audit; import java.io.Serializable; import java.text.DateFormat; import java.util.Date; import org.hibernate.envers.RevisionNumber; import org.hibernate.envers.RevisionTimestamp; import org.hibernate.envers.RevisionEntity; import javax.persistence.Id

Hibernate Envers: “withModifiedFlag” is not set to 1 on INT column value changed to NULL

安稳与你 提交于 2019-12-08 12:43:56
问题 I have the @Audited(withModifiedFlag = true) annotation on all the Entity properties which needs to be captured in my Audit table. It is working great for all the cases, except for value deletion. Meaning, If the value of my column is set from NULL/INT to some non-null value, then the corresponding modifiedColumn value is set to 1, But if the value is set from any INT value to NULL then the modifiedColumn is set to 0(indicates not modified). I have no clue why this is happening. I have

Hibernate Envers with Spring using HibernateTemplate

徘徊边缘 提交于 2019-12-08 03:39:49
问题 I'm trying to setup Envers in a Spring environment. Everything works fine, when I retrieve a session manually from the SessionFactory and put everything inside a Transaction: Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); TestEntity test = new TestEntity(); test.setTest("REV1"); session.save(test); tx.commit(); tx = session.beginTransaction(); test.setTest("REV2"); session.save(test); tx.commit(); The above code inserts data into the TestEntity

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

谁都会走 提交于 2019-12-08 02:52:01
问题 I am developing a RESTful API using Spring Data REST. Now for auditing, Spring does have the option to auditing meta data like created_date and modified_date but they don't provide entity versioning. Currently there are two popular libraries for entity version which are Envers and Javers. I have looked over for a comparison of both but there arent any articles on this matter. So what are the benefits and drawbacks of using Javers over Envers? 回答1: There are two big difference between JaVers

Audit trail with Hibernate Envers: How to trail only selected changes on entity?

℡╲_俬逩灬. 提交于 2019-12-08 00:13:54
问题 I have already implemented audit trail using hibernate envers for my entities and it works fine. Any changes (insert,update,delete) are stored in _AUD tables. Now I want to extend my audit and trail changes when one entity property has changed only. I want to store that change to additional table. In addition to the existing TABLE_AUD table which is tracking all changes in the entity, I need a second table TABLE_AUD2 that will track changes based on the one entity property only. What is

Hibernate envers custom revision entity

北慕城南 提交于 2019-12-07 17:50:54
问题 I'm trying to extend my revision table. Following the manual I created custom revision entity: package com.terminal.audit; import org.hibernate.envers.DefaultRevisionEntity; import org.hibernate.envers.RevisionEntity; import org.hibernate.envers.RevisionNumber; import org.hibernate.envers.RevisionTimestamp; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Transient; import java.util.Date; @Entity @RevisionEntity

Can I create Hibernate Envers specific tables using Liquibase

三世轮回 提交于 2019-12-07 00:17:54
问题 Our Java app is Spring based and we have domain classes and the corresponding schema generated via Liquibase. We are planning to add support for a single domain to be audited. a. We don't have hibernate.xml and hibernate.cfg.xml instead we are using application-context.xml. Then how do I create audit table through annotations like @Audited. How do I solve this issue? I have added hibernate configuration as <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org

Hibernate Envers - Get Fields that have changed

筅森魡賤 提交于 2019-12-06 19:37:28
问题 I have a rather complicated DB structure that I am trying to audit. Currently I have Envers running and it audits the changes that are made to each object. This works really well! I now want to show some audit information on the UI. The objects/tables get quite complicated so I was looking for a way to see what fields have changed in the audit. Currently Envers stores a snapshot of each object stamped with a revision id. I can look at each object's revision and then manually query to see what

AuditException: Unable to create revision because of non-active transaction

徘徊边缘 提交于 2019-12-06 14:48:07
I have been updating the frameworks on my application and now I'm trying to configure hibernate envers with JPA to audit some domains. Regular persistence is working properly by Audit is failing with the error below I've got this error org.springframework.orm.hibernate4.HibernateSystemException: Unable to create revision because of non-active transaction; nested exception is org.hibernate.envers.exception.AuditException: Unable to create revision because of non-active transaction at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java

Does HibernateTemplate work with Envers? If so, how?

孤者浪人 提交于 2019-12-06 11:33:24
I am trying to use Envers on a project that also uses Hibernate and Spring - and I appreciate a lot the code reduction offered by HibernateTemplate. I configured Envers under JPA, and after a few tweaks I was able to have the schema generated by the EnversHibernateToolTask Ant task (including the auditing tables). However, when I write code such as: hibernateTemplate.saveOrUpdate(f); the data is persisted, but nothing goes to the auditing tables. Conversely, if I write: EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); em.persist(f); em.getTransaction().commit(); then