0
我一直在創建審計表。我有兩個集合的一對多關係。一旦相反,另一個不是。可審計加入註釋適用於非反向釋放,但不適用於反向釋放。不產生JPA休眠和審計加入表
我的代碼
@Entity
@Audited
@AuditTable(value = "DDD")
public class Department {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Audited
private int id;
private int age;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
private String name;
@OneToMany(targetEntity = Professor.class,cascade = CascadeType.ALL)
@JoinColumn(name = "dept_id")
@AuditJoinTable(name = "abc")
private java.util.Collection<Professor> employees;
@OneToMany(targetEntity = Address.class, mappedBy = "department")<==inverse relation
@AuditJoinTable(name = "def")
//I tried commenting this out and let the inverse side AuditJoinTable annotation, no luck
private java.util.Collection<Address> addresses;
//Getters and setters remove to reduce clutter
}
地址
@Entity
@Audited
public class Address {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private int id;
@Column
private String name;
@ManyToOne(cascade = CascadeType.ALL)
@AuditJoinTable(name = "def")
private Department department;
教授
@Entity
@Audited
public class Professor {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private int id;
@Column
private String name;
private long salary;
@ManyToOne
@JoinColumn(name = "dept_id")
private Department department;
}
當我創建使用hibernate.hbm2ddl.auto 「高清」 autdit表scema。但是,會生成「abc」審計聯接表,並且在更新僱員集合時會記錄審計條目。
我使用 休眠/休眠-envers - 3.6.9.Final JPA 1.0
任何指針讚賞