我試圖得到一個簡單的envers例子工作。我有Java代碼工作(顯然),我終於got the org.hibernate.tool.ant.EnversHibernateToolTask to work,但它只輸出SQL的「常規」數據,而不是版本控制數據。我很難接下來做什麼。難以得到一個簡單的例子工作:問題#34
我可能忘記了什麼?
這裏是它輸出SQL:{版本控制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;
我沒有看到任何歷史記錄表/字段。下面是我的hibernate.cfg.xml文件中的相關條目:Java類的
<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>
相關部分:
@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;
...
}
您正在使用什麼Hibernate和envers的版本? – 2009-08-17 17:38:08