Using Hibernate Envers, while doing create operation audit functionality is properly working data is correctly filled up in main as well as audit table but while deleting an entry for few fields its taking null following is the code sample:
@Audited
@MappedSuperclass
public abstract class A implements Serializable
{
private static final long serialVersionUID = 1L;
@NotNull
private Long id;
@NotNull
private String user;
private Timestamp time;
}
@Entity
@Audited
public class B extends A
{
private static final long serialVersionUID = 1L;
@EmbeddedId
private EmbeddedId embeddedId;
@ManyToOne
@JoinColumn(name = "CODE")
private Code code;
}
@Audited
@Embeddable
public class EmbeddedId implements Serializable
{
private static final long serialVersionUID = 1L;
@ManyToOne
@JoinColumn(name = "C")
private C c;
@ManyToOne(optional = false)
@JoinColumns(value =
{ @JoinColumn(name = "C_ID", referencedColumnName = "C_ID"),
@JoinColumn(name = "D_ID", referencedColumnName = "D_ID") })
private D d;
}
@Entity
@Audited
public class Code extends A
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long cId;
private String name;
}
All the classes are annotated with @Audited, when delete operation is fired Class B data is not properly getting audited. Data corresponding to the embeddedId (composite primary key) is reflecting in audit table but other data like (code, id, user, time) i.e member variable of that class as well as coming from inheritance are going as null in audit table.
Please provide with the detailed solution for this issue as i am new to Envers.