hibernate-envers

How to retrieve audited register with relationship @ManyToOne using Hibernate Envers

半腔热情 提交于 2019-12-03 17:32:48
I´m doubt about using Hibernate Envers and my class. I have a class Loja . @Entity @Audited @GenericGenerator(name = "Sequence_Generic", strategy = "com.paradigma.ecred.dao.hibernate.generator.ManualGenerator") // sequence generic criado para a atividade 510 @SelectBeforeUpdate @DynamicUpdate public class Loja extends Persistent { @Trim @NotBlank(message = "O preenchimento do campo \"CNPJ\" é obrigatório.") @CNPJ(message = "O \"CNPJ da loja\" é inválido") private String cnpj; @Trim @NotBlank(message = "O preenchimento do campo \"Razão social\" é obrigatório.") @Size(max = 255, message = "A

How to generate Envers database schema with org.hibernate.tool.EnversSchemaGenerator?

只谈情不闲聊 提交于 2019-12-03 16:48:43
I updated Hibernate to the 4.1.1.Final version. According to the documentation There are 2 ways to generate a database schema: Ant task org.hibernate.tool.ant.EnversHibernateToolTask . Run org.hibernate.tool.EnversSchemaGenerator from Java. Hibernate-tools doesn't work with Hibernate-4.1.1.Final. It has a blocking bug . I found only release notes and a test case . So how can I use org.hibernate.tool.EnversSchemaGenerator with my persistence.xml and Maven? Update: Found related thread on the Hibernate forum . It seems there is no answer to my question yet. Juplo has created Maven plugin for

How to manage object revisions in Grails?

笑着哭i 提交于 2019-12-03 11:03:18
I need to implement a revision system for articles in my grails web app. After searching grails forum, stackoverflow, grails plugins and googling internet, I have ended up with 3 options: Option 1 - Using the grails Envers plugin (see http://code.google.com/p/grails-envers-plugin/ ). Has anyone used it successfully? Or using Envers without the plugin (see here ) but how can I make it work with GORM? Option 2 - Using the Gvers plugin I have found out here: https://github.com/ziftytodd/gvers . I never heard anyone using it, so is there anybody who have ever used it successfully? Option 3 - Built

Get previous version of entity in Hibernate Envers

心已入冬 提交于 2019-12-03 04:34:59
问题 I have an entity loaded by Hibernate (via EntityManager ): User u = em.load(User.class, id) This class is audited by Hibernate Envers. How can I load the previous version of a User entity? 回答1: maybe this then (from AuditReader docs) AuditReader reader = AuditReaderFactory.get(entityManager); User user_rev1 = reader.find(User.class, user.getId(), 1); List<Number> revNumbers = reader.getRevisions(User.class, user_rev1); User user_previous = reader.find(User.class, user_rev1.getId(), revNumbers

Why cant I close HibernateSessionFactory and reopen it and it still work?

℡╲_俬逩灬. 提交于 2019-12-02 20:12:02
问题 I'm having a problem with closing Hibernate Session Factory, my application allows the user to recreate the database, so when they want to do that firstly I close the hibernate session factory to free Hibernates grip on the database. public static void closeFactory() { if(factory != null) { factory.close(); } } Then I wait a few seconds which seems to help Thread.sleep(10000); Then I recreate the database, (FWIW regular hibernate and Envers - I need to create factory for Envers tables to be

Get previous version of entity in Hibernate Envers

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 18:53:15
I have an entity loaded by Hibernate (via EntityManager ): User u = em.load(User.class, id) This class is audited by Hibernate Envers. How can I load the previous version of a User entity? maybe this then (from AuditReader docs) AuditReader reader = AuditReaderFactory.get(entityManager); User user_rev1 = reader.find(User.class, user.getId(), 1); List<Number> revNumbers = reader.getRevisions(User.class, user_rev1); User user_previous = reader.find(User.class, user_rev1.getId(), revNumbers.get(revNumbers.size()-1)); (I'm very new to this, not sure if I have all the syntax right, maybe the size()

Why cant I close HibernateSessionFactory and reopen it and it still work?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 08:47:59
I'm having a problem with closing Hibernate Session Factory, my application allows the user to recreate the database, so when they want to do that firstly I close the hibernate session factory to free Hibernates grip on the database. public static void closeFactory() { if(factory != null) { factory.close(); } } Then I wait a few seconds which seems to help Thread.sleep(10000); Then I recreate the database, (FWIW regular hibernate and Envers - I need to create factory for Envers tables to be created), and close the factory down again. public static void recreateDatabase() { Configuration config

Hibernate Envers : track revisions in the owning side of a OneToMany relation

戏子无情 提交于 2019-12-02 04:17:04
问题 I have two audited entities, A and B. Entity A holds a collection of entity B (annotated as One-to-many relationship). When inserting a new instance of A into the database, all rows of A and B are at the same revision (let's say revision 1). Then, there is an update on A which only affect the instances of entity B (cascade type is merge). So after the update, the entity A is still at revision 1, whereas the entities of B are at revision 2 (new MOD entry in the audit table). The problem is

Work around for envers auditing for bulk update

谁说胖子不能爱 提交于 2019-12-02 03:37:03
问题 In the application which I am working on I use spring, hibernate and envers for auditing. envers works with calls like, hibernateTemplate.insert , hibernateTemplate.save , hibernateTemplate.saveOrUpdate . But it doesnt seem to work when i call hibernateTemplate.bulkUpdate . I googled for solutions and found that envers doesnt support bulkUpdate. A work around has been provided in the link below but i am not able to get it. Envers Bulk insert/updates It would be of help if someone can provide

Hibernate Envers : track revisions in the owning side of a OneToMany relation

僤鯓⒐⒋嵵緔 提交于 2019-12-02 02:12:22
I have two audited entities, A and B. Entity A holds a collection of entity B (annotated as One-to-many relationship). When inserting a new instance of A into the database, all rows of A and B are at the same revision (let's say revision 1). Then, there is an update on A which only affect the instances of entity B (cascade type is merge). So after the update, the entity A is still at revision 1, whereas the entities of B are at revision 2 (new MOD entry in the audit table). The problem is when I retrieve all the revisions of A, I would expect to get 2 revisions in return : one for the creation