hibernate-envers

Hibernate Entity Auditing and hbm2ddl.auto=validate in h2 and oracle

早过忘川 提交于 2019-12-25 04:33:33
问题 I have a problem with schema validation of revtype column of audit tables I have declared revtype column as number(3) everything is working fine when i'm using oracle database but when i'm switch to h2 i have exception revtype revtype column found decimal expected tinyint Any ideas how can it works on h2 and oracle ? 回答1: Extending h2 dialect and changing column definition for integer worked 来源: https://stackoverflow.com/questions/35925228/hibernate-entity-auditing-and-hbm2ddl-auto-validate

How do I create custom field to store user credentials in REVINFO table

六月ゝ 毕业季﹏ 提交于 2019-12-25 03:34:45
问题 We are using hibernate-envers and having *_AUD table that stores historical state of entities. There is also a global REVINFO table which contains revision number, timestamp. I need to add user as field in REVINFO table. How to add "user" field in REVINFO table? 回答1: You can definitely create your custom RevisionInfo entity. The custom revisions entity must have an integer-valued unique property (preferably the primary id) annotated with {@link RevisionNumber} and a long-valued property

Hibernate Envers get revisions for criteria

守給你的承諾、 提交于 2019-12-25 02:38:59
问题 Using Hibernate Envers (4.1.9.Final). Trying to get all the revisions (date, revision number) for which a entities have changed of a certain type and that match a certain criterion. This is the code that I'm currently having: AuditReader auditReader = AuditReaderFactory.get(entityManager); AuditQuery query = auditReader.createQuery() .forRevisionsOfEntity(InventoryItem.class, false, true) .add(AuditEntity.property("section_uuid").eq(sectionUuid)) .addOrder(AuditEntity.revisionNumber().desc())

Unable to fetch Object in Hibernate Envers

ぃ、小莉子 提交于 2019-12-25 01:55:46
问题 I'm trying to display the values in the RefAuthorizationVO Object when I call the DuaVO Object. But, when I debug it, the value is shown as null. I'm passing an authorizationCode as "BENE" and wanted the particular column fetch from the RefAuthorization Table. But, I all I see is a null. I'm kinda lost here. Main Class public void getDuaObject() { // findAuditByRevision("DuaNum", Revision Number); DuaVO dua = findAuditByRevisionNum("1", 1026); } 来源: https://stackoverflow.com/questions

Hibernate Envers : How to check if a field has changed between two revisions?

本小妞迷上赌 提交于 2019-12-24 16:08:41
问题 I am using Hibernate envers to audit entities in my application. I have separate _audit tables for each entity and then in those tables I have _mod boolean column to indicate if the field has changed or not. But, I m not getting how to use that column in queries or even how do I get this data in the code? e.g. following code gives list of audited persons. How do I check which data has changed? List person = getAuditReader().createQuery() .forEntitiesAtRevision(Person.class, 12) .getResultList

Hibernate Envers revision info (changes list)

天大地大妈咪最大 提交于 2019-12-24 00:45:19
问题 I want to add in my project a list of the revision changes (on click in info icon) like: Revision X - added fieldA entry - modified fieladB from B to BB - removed fieldC entry ... Which is the best way? ps: I already use EntityTrackingRevisionListener. Thanks. 回答1: The best way currently is to load the history of an object (list of historical versions) and compare in Java. The latest release (4.1) also has support for adding modified flags (boolean, specify if a field was modified or not in

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

回眸只為那壹抹淺笑 提交于 2019-12-23 01:15:25
问题 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

hibernate envers does not get triggered for jpa queries

时光怂恿深爱的人放手 提交于 2019-12-22 10:38:06
问题 I am using hibernate envers to audit events and it works fine along with Spring Data JPA Repository when i invoke repositoy.delete() or repository.save() But If I write a jpa query and delete the entity using a query , then it hibernate envers audit listener does not get invoked. I read that hibernate envers will not trap native query - But will it not work for hibernate/jpa queries as well ? Thanks Lives 回答1: As mentioned in this and this post, envers is not triggered in your situation. Also

How to delete entries from my audit table?

百般思念 提交于 2019-12-22 05:02:43
问题 I am currently working with Hibernate Envers. How to delete entries in the audit table related to the entity I want to delete? My entity has no relation with other entities. I figured out that I have to do that in onPostDelete method of my custom listener: import org.hibernate.envers.event.AuditEventListener; import org.hibernate.event.PostCollectionRecreateEvent; import org.hibernate.event.PostDeleteEvent; import org.hibernate.event.PostInsertEvent; import org.hibernate.event.PostUpdateEvent

Why Hibernate Envers is ignoring my custom RevisionEntity?

♀尐吖头ヾ 提交于 2019-12-21 20:19:30
问题 I'm developing an application using JPA 2.1 (supported by hibernate 4.2.11) with spring 4.0.2. We are using Envers for auditing changes in project entities. That is working fine. The problem comes when we try to use custom Revision Entity as Envers documentation says: http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-revisionlog We have made a custom class and a custom listener as pointed in the documentation but it seems that they are totally ignored by Hibernate.