Hibernate version: 3.2 (annotations 3.3.1, entitymanager 3.3.2)
Name and version of the database you are using: HSQLDB 1.8.0.9
I have 2 classes (Computer and Software) with a ManyToMany association. Since the access is always done from the Computer side, the Software Entity has no coresponding ManyToMany field.
Any change made to a Computer should be logged (with the preUpdate method).
Code:
@Entity
public class Computer {
@Id @Generated
private long id;
private String name;
@ManyToMany
private Collection<Software> software;
getters and setters...
@PreUpdate
public void preUpdate{
System.out.println("Computer updated");
}
}
@Entity
public class Software {
@Id @Generated
private long id;
private String name;
getters and setters...
}
When I change the name of a Computer, the preUpdate is called as it should, but when I add a Software to a Computer's software Collection, the preUpdate method is NOT called.
Is this behaviour normal or am I doing something wrong? How can I make the preUpdate method beeing called when a collection is changed?