I have a join table with a name like "baker_buns" generated from an @ManyToMany mapping which has two columns: bakers_id and buns_id.
How can I get hibernate to also add a timestamp column to this table which will be set to current time whenever a row is added to the table?
The annotated code looks something like this:
Code:
@Entity
public class Baker {
private Set<Bun> buns;
// ...
@ManyToMany
public Set<Bun> getBuns() {
return buns;
}
public void setBuns(Set<Bun> buns) {
this.buns = buns;
}
}
@Entity
public class Bun {
private Set<Baker> bakers;
// ...
@ManyToMany( mappedBy="buns" )
public Set<Baker> getBakers() {
return bakers;
}
public void setBakers(Set<Baker> bakers) {
this.bakers = bakers;
}
}