Hi am reading the hibernate documentation.
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html
A many-to-many association is defined logically using the @ManyToMany
annotation. You also have to describe the association table and the
join conditions using the @JoinTable annotation. If the association is
bidirectional, one side has to be the owner and one side has to be the
inverse end (ie. it will be ignored when updating the relationship
values in the association table):
I understand everything but the last
(ie. it will be ignored when updating the relationship values in the association table).
What does this mean? Example?
Suppose you have the following entities:
The owner side is Student (because it doesn’t have the
mappedByattribute). The inverse side is Course ((because it has themappedByattribute).If you do the following:
Hibernate will add an entry for student 4 and course 3 in the join table because you updated the owner side of the association (
student.courses).Whereas if you do the following:
nothing will happen, because uou updated the inverse side of the association (
course.students), but neglected to updated the owner side. Hibernate only considers the owner side.