我看过很多类似的问题,例如:http: //community.jboss.org/message/580407#580407但还没有找到解决方案。
一个活动有许多事件,当一个事件被创建时,activity_occurence_AUD 表被正确更新为 0(创建)修订。
但是,当删除发生时,activity_occurence_AUD 表不会填充 2(删除)修订。
活动实体:
@Entity
@Table(name = "activity")
@Audited
public class Activity implements Serializable {
private static final long serialVersionUID = 1L;
public static final int[] VALID_PRIORITIES = { 0, 1, 2, 3 };
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id", nullable = false)
private Long id;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "activity")
private List<ActivityOccurrence> activityOccurrenceList;
....
}
ActivityOccurence Entity:
@Entity
@Table(name = "activity_occurrence")
@Audited
public class ActivityOccurrence implements Comparable<ActivityOccurrence>, Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id", nullable = false)
private Long id;
@JoinColumn(name = "activity_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false)
private Activity activity;
....
}
休眠属性:
<entry key="hibernate.ejb.event.post-insert"
value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" />
<entry key="hibernate.ejb.event.post-update"
value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" />
<entry key="hibernate.ejb.event.post-delete"
value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" />
<entry key="hibernate.ejb.event.pre-collection-update"
value="org.hibernate.envers.event.AuditEventListener" />
<entry key="hibernate.ejb.event.pre-collection-remove"
value="org.hibernate.envers.event.AuditEventListener" />
<entry key="hibernate.ejb.event.post-collection-recreate"
value="org.hibernate.envers.event.AuditEventListener" />
任何帮助将非常感激。
奇怪的是更新有效但删除无效。
让我知道我是否可以提供更多信息。