I'm trying to get a simple envers example to work. I have the Java code working (apparently), and I finally got the org.hibernate.tool.ant.EnversHibernateToolTask to work, but it only outputs SQL for the "regular" data, not the versioning data. I'm stumped for what to do next.
What might I be forgetting to include?
Here is the SQL it outputs: {versioning-ddl.sql}
create table Event (
id bigint generated by default as identity (start with 1),
date timestamp,
title varchar(255),
primary key (id)
);
create table Person (
id bigint generated by default as identity (start with 1),
age integer not null,
firstname varchar(255),
lastname varchar(255),
primary key (id)
);
create table PersonEvent (
eventID bigint not null,
personID bigint not null,
primary key (eventID, personID)
);
alter table PersonEvent
add constraint FK489E5C25F6E47374
foreign key (personID)
references Event;
alter table PersonEvent
add constraint FK489E5C25729F3820
foreign key (eventID)
references Person;
I don't see any history tables/fields. Here are the relevant entries in my hibernate.cfg.xml file:
<hibernate-configuration>
<session-factory>
...
<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>
<mapping class="com.example.test.hibernate.test1.Event"/>
<mapping class="com.example.test.hibernate.test1.Person"/>
</session-factory>
</hibernate-configuration>
and relevant portions of Java classes:
@Entity
@Audited
public class Event {
@Id
@GeneratedValue
private Long id;
private String title;
private Date date;
...
}
@Entity
@Audited
public class Person {
@Id
@GeneratedValue
private Long id;
private int age;
private String firstname;
private String lastname;
...
}