-
1. Re: Envers configuration with hibernate.cfg.xml
adamw May 26, 2011 2:53 AM (in response to shyenuganti)Maybe you can try setting a breakpoint on AuditEventListener to see if the listener is invoked?
Adam
-
2. Re: Envers configuration with hibernate.cfg.xml
shyenuganti May 26, 2011 11:03 AM (in response to adamw)Yes, I tried to build a custom event listener that just does nothing but logs and delegates the call to AuditEventListener. The post-update method is being called. But the audit tables are not being updated !!
-
3. Re: Envers configuration with hibernate.cfg.xml
shyenuganti May 26, 2011 12:13 PM (in response to shyenuganti)Do we need to add "EJB3Post...EventListener"s to the hibernate config file for the Envers persistance to work properly? If Yes, where and how should we add them?
-
4. Re: Envers configuration with hibernate.cfg.xml
shyenuganti May 26, 2011 12:59 PM (in response to shyenuganti)Am I missing any transaction configuration settings in my hibernate.cfg.xml? Which transaction manager should I use for Envers to work?
-
5. Re: Envers configuration with hibernate.cfg.xml
shyenuganti May 26, 2011 1:55 PM (in response to shyenuganti)I have added the transaction managers in the config file. This worked.
Now I get this error :
com.ibm.db2.jcc.c.SqlException: "IMGTEST.REVINFO" is an undefined name.
I dont know why it is going for IMGTEST schema when the default schema is defined as ROCC in the cofig file.
Is there any other attribute that I have to set to specify the schema for REVINFO table?
-
6. Re: Envers configuration with hibernate.cfg.xml
adamw May 26, 2011 2:36 PM (in response to shyenuganti)I think there's a bug with the revision entity not respecting the default schema setting.
Try creating a custom revision entity (there's an example in the doc, it can contain just the revision number and revision timestamp fields), and place an @Table annotation with the schema specified on it.And you need transactions as you already found out for Envers to work, that's correct . Luckily you normally want transactions anyway
Adam
-
7. Re: Envers configuration with hibernate.cfg.xml
shyenuganti May 26, 2011 3:39 PM (in response to adamw)Thank You Adam ! That solved my issue. I have a created a custom Revision Entity and added it to my hibernate.cfg.xml.
I think this Revision Entity bug is happening only when you use the Hibernate Session factory instead of EntityManager. And also if you use hibernate from Spring using HibernateTemplate, we are not seeing this issue.
Here I have another question. If I close the session after inserting into the main table, the Envers is not doing the auditing saying THE SESSION IS ALREADY CLOSED. If I leave the session open without closing, the auditing is working.
So will ENVERS close the open session after inserting into the audit tables? If not, there willl be number of open sessions that are not closed !!