-
1. Re: Envers doesn't create audit table
hhde Mar 27, 2009 11:14 AM (in response to gambellid)What is your hibernate.hbm2ddl.auto setting? It seems that the audit tables are created only when using create or create-drop.
-
2. Re: Envers doesn't create audit table
gambellid Mar 27, 2009 12:52 PM (in response to gambellid)I have resolvede this problem, I have a bad configuration into the hibernatContext.xml.
Now the problem is about the hbernate version: I have jboss-as 4.2.3 and spring 2.5, which jars file for hibernate I need to use to have a correct configuration with envers?
Thanks in advance -
3. Re: Envers doesn't create audit table
amorelos Mar 28, 2009 10:26 PM (in response to gambellid)Hello everybody,
I'm actually having the same problem, the audit tables are not being created (but there are no problems with the other tables), I'm currently doing this work for a standalone application, and I'm using native Hibernate (so I'm using a hibernate.cfg.xml file), anyway I'm annotating my classes just to get Envers' audit support.
I'm using the following:
Envers 1.2.0
DB2 8.1
Hibernate 3.3.1
Hibernate Annotations 3.4.0
Hibernate Commons Annotations 3.1.0
Ant 1.7.0
Java 1.5
This is my target definition in Ant:<target name="schemaexport" description="Exports a generated schema to DB and file"> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.EnversHibernateToolTask" classpathref="project.classpath"/> <hibernatetool destdir="${basedir}"> <classpath path="${build.dir}" /> <annotationconfiguration configurationfile="${build.dir}/hibernate.cfg.xml"/> <hbm2ddl drop="true" create="true" export="true" outputfilename="db-ddl.sql" delimiter=";" format="true" /> </hibernatetool> </target>
This is a simplified view of my hibernate.cfg.xml file:<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property> <property name="dialect">org.hibernate.dialect.DB2Dialect</property> <property name="show_sql">true</property> <mapping resource="mypackage/Order.hbm.xml" /> <mapping resource="mypackage/OrderFeatures.hbm.xml" /> <event type="post-insert"> <listener class="org.hibernate.envers.event.AuditEventListener" /> </event> <event type="post-update"> <listener class="org.hibernate.envers.event.AuditEventListener" /> </event> <event type="post-delete"> <listener class="org.hibernate.envers.event.AuditEventListener" /> </event> </session-factory> </hibernate-configuration>
Any ideas? What may I need to change? Do you spot any bugs?
Thanks in advance! -
4. Re: Envers doesn't create audit table
amorelos Mar 29, 2009 12:37 PM (in response to gambellid)Ok, I found an error in hibernate.cfg.xml file, I had:
<mapping resource="mypackage/Order.hbm.xml" /> <mapping resource="mypackage/OrderFeatures.hbm.xml" />
And I just found that I had to do the mapping like this:<mapping class="myPackage.Order"/> <mapping class="mypackage.OrderFeatures" />
Anyway, I'm still having the same problem, the audit tables are not generated.
Thanks! -
5. Re: Envers doesn't create audit table
adamw Mar 31, 2009 5:42 AM (in response to gambellid)Hello,
do you have any exceptions? Do you have the correct setting for "hbm2ddl.auto" (create-drop or update)?
You need all the newest Hibernate jars with dependencies (annotations, commons-annotations, validator, search, slf4j, entity manager) and it should work fine.
Adam -
6. Re: Envers doesn't create audit table
benblock Mar 31, 2009 6:36 AM (in response to gambellid)I have the same Problem.
My hibernate.cfg.xml contains:<property name="hibernate.ejb.event.post-insert">org.hibernate.envers.event.AuditEventListener</property> <property name="hibernate.ejb.event.post-update">org.hibernate.envers.event.AuditEventListener</property> <property name="hibernate.ejb.event.post-delete">org.hibernate.envers.event.AuditEventListener</property> <property name="hibernate.ejb.event.pre-collection-update">org.hibernate.envers.event.AuditEventListener</property> <property name="hibernate.ejb.event.pre-collection-remove">org.hibernate.envers.event.AuditEventListener</property> <property name="hibernate.ejb.event.post-collection-recreate">org.hibernate.envers.event.AuditEventListener</property> <property name="hibernate.hbm2ddl.auto">create-drop</property> <property name="hibernate.show_sql">true</property> <property name=" org.hibernate.envers.auditTableSuffix">_REV</property> <property name=" org.hibernate.envers.auditTablePrefix"></property>
My Ant-Task:<target name="create" depends="compile"> <hibernatetool destdir="."> <annotationconfiguration configurationfile="${hibernate.dir}/hibernate.cfg.xml" /> <classpath refid="classes" /> <hbm2ddl export="true" create="true" /> </hibernatetool> </target>
The "normal" tables are created, the audit tables are missing.
Works fine by the way if deployed with a persistence.xml Configuration. -
7. Re: Envers doesn't create audit table
benblock Mar 31, 2009 6:40 AM (in response to gambellid)ps. my ant-file also contains:
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.EnversHibernateToolTask" classpathref="toolslib" />
-
8. Re: Envers doesn't create audit table
adamw Apr 1, 2009 11:49 AM (in response to gambellid)Hello,
can somebody maybe create a simple test case and create a JIRA issue with it attached? :)
Adam