I have a simple many to many association like below

1.User(UserId)
2.UserProjects(UserId,ProjectId,RowId)
3.Projects(ProjectId)


When I do a mapping with many to many with a bag collection of Users
in Projects the nhibernate query generated for adding a user to
project turns out to be

Dim p as Project = ProjectRepository.GetById(1)
Dim u as User = UserRepositoy.GetUser("Yuvan")
p.Users.Add(u)
p.SaveorUpdate()
[Note I already have users asscoiated with the project]

Nhibernate Query : Delete From UserProject Where ProjectId=1
Nhibernate Query : Insert into UserProject(1,"Yuvan")
Nhibernate Query : Insert into UserProject( ....)
Nhibernate Query : Insert into UserProject( ....)

When I do a mapping with a Iset collection there is no issues.Only one
insert for the newly associated user.
I do  lazy loading for all collections and my cascades are set
properly.

So is this how bag collection works for many-to-many mapping ( deletes
all the rows in the association table and do an insert) or is that I
am missing something. I see a lot of docs and online examples using
bag for the many-to-many??However when I use bags for one-to-many
mapping and add/change collections I dont see this behaviour??
Can someone out there please explain me why???Please????





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to