0
使用Glassfish 3.1.2和eclipselink 2.2.0。 我必須跟蹤以下實體的變化:對OneToOne屬性的審計
@Entity
@EntityListeners({AuditListener.class})
@Customizer(AuditListener.class)
public class Client extends Person {
...
@OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
private ConsumptionRoomAndPost consumptionRoomAndPost;
...
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
private List<Document> documentList;
...
AuditListener:
public class AuditListener extends DescriptorEventAdapter implements DescriptorCustomizer {
...
@Override
public void postMerge(DescriptorEvent event) {
if (event.getChangeSet() != null) {
...
}
}
}
這適用於文檔列表,變更爲不爲空, 而不是ConsumptionRoomAndPost 。 changeSet是空的。
當然,我可以爲ConsumptionRoomAndPost添加自己的偵聽器ConsumptionRoomAndPostAuditListener,但對於審計,我需要客戶端信息,並且我有問題可以將此客戶端信息提供給ConsumptionRoomAndPostAuditListener。