Hiya.
I can't find any documentation on how to receive PostUpdate/PostInsert events on a many-to-many relationship. Is this possible?
I have 2 classes - LiveMember and Genre. They share a many-to-many relationship, and I need notification when my LiveMember changes any of his Genres. However, since all inserts/updates/deletes occur in the join table, no event is ever fired to the LiveMember or Genre object.
My [Pre|Post][Update|Insert]Listeners are all registered programatically, and fire appropriately when changes are made to the entity's direct fields.
Anyone with experience in this?
Thanks in advance!
S,
ALR
Hibernate version:
Bundled w/ JBoss EJB3 RC9 Patch 1
Mapping documents:
Annotations
Code:
@Entity
public class Genre{
...
@ManyToMany(mappedBy = "genres")
public Collection<LiveMember> getLiveMembers() {
return liveMembers;
}
}
Code:
@Entity
public class Band{
...
@ManyToMany
@JoinTable(name = "sync_live_join_band_genre")
public Collection<Genre> getGenres() {
return genres;
}
}
Name and version of the database you are using:MySQL 5.0.27 Community
The generated SQL (show_sql=true):Code:
145 Prepare [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (?, ?)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 101)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 102)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 103)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 104)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 106)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 107)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 108)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 109)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 110)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 111)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 112)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 113)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 114)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 115)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 116)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 117)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 118)
145 Execute [172] insert into sync_live_join_livemember_genre (liveMembers_id, favoriteGenres_id) values (10000, 100)
145 Query XA END 0x3233322e3136342e31322e3231362e696e76697369626c6568616e642e6e65742f313532,0x32,0x101
145 Query XA PREPARE 0x3233322e3136342e31322e3231362e696e76697369626c6568616e642e6e65742f313532,0x32,0x101
145 Query XA COMMIT 0x3233322e3136342e31322e3231362e696e76697369626c6568616e642e6e65742f313532,0x32,0x101
[/code]