-
1. Setting up envers in maven/eclipse
adamw Mar 3, 2011 3:35 AM (in response to chrismm)If you have hbm2ddl.auto set to update or create, then the tables will be automatically created (just like tables for regular entities).
If you'd like to generate the schema, there's an Ant task for that: http://docs.jboss.org/hibernate/envers/3.6/reference/en-US/html_single/#schema
In the pom, you only need to add the dependency on the Envers module.
Adam -
2. Setting up envers in maven/eclipse
chrismm Mar 3, 2011 10:36 AM (in response to adamw)Hi Adam,
I cant get the _AUD tables to be generated ??
Heres my hibernate.cfg.xml :-
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@192.168.181.79:1521:ORARCDQ</property>
<property name="hibernate.connection.username">rs_dev</property>
<property name="hibernate.connection.password">rs_dev</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<!-- Mapping classes -->
<mapping class="com.iontrading.RS.database.Article"/> <!-- This Class has @Audited set -->
<mapping class="com.iontrading.RS.database.Directory"/>
<mapping class="com.iontrading.RS.database.Filter"/>
<mapping class="com.iontrading.RS.database.Report"/>
<mapping class="com.iontrading.RS.database.Template"/>
<!-- Envers interceptors, called when an audited table has an update/delete/create called on it. -->
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-delete"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-remove"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-collection-recreate"/>
</session-factory>
</hibernate-configuration>
heres the Article.java file (elided)
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.envers.Audited;
@Entity
@Table( name="ARTICLE")
@Audited
public class Article
{
@Id Long id;
@Column( name="FILTER_ID", nullable= false) Long filterId;
@Column( name="TEMPLATE_ID") Long templateId;
@Column( name="REF_ARTICLE_ID")Long refArticleId;
@Column( name="TYPE")String type;
@Column( name="CREATION_DATE")String creationDate;
... etc
and heres the entry in the pom.xml
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>3.5.6-Final</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
What have I done wrong ??
-
3. Setting up envers in maven/eclipse
adamw Mar 3, 2011 2:01 PM (in response to chrismm)Did you start your application with these settings?
Adam
-
4. Setting up envers in maven/eclipse
chrismm Mar 7, 2011 6:11 AM (in response to adamw)Hi Adam, Ive found out this was due to a different hibernate.cfg.xml being picked up further up the classpath.
Thanks for your help.
Chris.