Hi.
I'm implementing audit info in my VO object. Before save objects in database i call mathod setLastUpdateDate, and setUpdatedBy. I have a problem with children in collections. For example, my parent class.
Code:
public class Parent {
private long id;
private Set children;
private Date lastUpdateDate;
private User updatedBy;
public long getId() { return id; }
private void setId(long id) { this.id=id; }
private Set getChildren() { return children; }
private void setChildren(Set children) { this.children=children;
private User getUpdatedBy() { return updatedBy; }
private void setUpdatedBy(User updatedBy) { this.updatedBy=updatedBy; }
}
Children class:
Code:
public class Parent {
private long id;
private Date lastUpdateDate;
private User updatedBy;
public long getId() { return id; }
private void setId(long id) { this.id=id; }
private Date getLastUpdateDate() { return lastUpdateDate; }
private void setLastUpdateDate(Date date) { this.lastUpdateDate=date; }
private User getUpdatedBy() { return updatedBy; }
private void setUpdatedBy(User updatedBy) { this.updatedBy=updatedBy; }
}
Before save Parent i call method setLastUpdateDate and setUpdatedBy. Is this possible to call also this 2 methods in children object VO? I want universal way of do this, because I have many VO objects, many diffrents collections in this objects and only one core class which is responsible for save objects and update audit info. Is there any adnotation to set a call method in collection before save them in database or any different solution?