hibernate-envers

How to retrieve the audited revision of relations?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 05:59:00
问题 Here is my use case I have two entities : Personn and Email (a @OneToMany relation). Both of them are audited. First I create a new Personn, with an Email (=> Both of them have a revision 1), then I modify the Email (=> The Email has a revision 2, but Personn has only a revision 1) In the web application the end-user has only one view to show the Personn's attributs and also his Emails attributs. In this view I want to show all existing revisions for this Personn. But when I query the audit

Hibernate Envers fails with @Converter and AttributeConverter (JPA 2.1)

无人久伴 提交于 2019-11-27 18:28:01
问题 I am using Hibernate 4.3.4 with Envers, and MySql 5.6. Without a JPA 2.1 converter, the Party entity below fails at Configuration.buildSessionFactory() as it should, since Hibernate doesn't know what to do with the Name class: @Entity @Audited public class Party { protected Name name; ... } The exception is: org.hibernate.MappingException: Could not determine type for: ModuloADM.Party.Name, at table: Party, for columns: [org.hibernate.mapping.Column(name)] To fix this, I then add this

Find max revision of each entity less than or equal to given revision with envers

北慕城南 提交于 2019-11-27 07:21:43
问题 This might be simple, but unable to find a way. I am trying to find max revision of each entity less than or equal to given revision number. AuditQuery query = getAuditReader().createQuery().forRevisionsOfEntity( entityClass, false, false); query.add(AuditEntity.revisionNumber().le(revisionNumber)); query.addOrder(AuditEntity.revisionNumber().desc()); query.getResultList(); Above code returns multiple revisions of same entity in descending order. I would like to get latest distinct revision

Extending Hibernate Envers Implementation

别说谁变了你拦得住时间么 提交于 2019-11-27 07:12:21
问题 I have 2 maven projects that share a JPA project as a dependency in their individual POMs. The JPA project is on ver 2.1 and has hibernate envers implemented successfully. However I now need to create a custom RevisionEntity as I need to audit extra properties such as the logged in user id. Problems are: i. I cant implement this directly in the JPA project ii. The implementation for retrieving the logged in user differs for the parent maven projects. The real challenge is actually in