Hi,

I have an entity which holds a collection of other entites. In the
database this tranlates to 3 tables.

[BuzzUser] {BuzzUserID, Name}
[BuzzUserArt] {BuzzUserArtID, Title}
[BuzzUserFavourites]{BuzzUserFavouritesID, BuzzUserID, BuzzUserArtID}


In the mapping of BuzzUser, I've mapped the third table to a bag :

  <bag name="Favourites" table="BuzzUserFavourites" lazy="false">
      <key column="BuzzUserID" />
      <many-to-many class="BuzzArt.BuzzUserArt, BuzzArt"
column="BuzzUserArtID" />
    </bag>

Now if I add a BuzzUserArt entity to the collection Favourites :

     if (! buzzUser.Favourites.Contains(buzzUserArt))
        buzzUser.Favourites.Add(buzzUserArt);

      _buzzUserDao.SaveOrUpdate(buzzUser);

Then NHibernate deletes all the favourites associated to this
BuzzUser :

DELETE FROM BuzzUserFavourites
WHERE       BuzzUserID = '306170f2-737f-402c-9731-9c63013c32db'


and then it adds them all again, including the one I wanted to add
initially :

INSERT INTO BuzzUserFavourites (BuzzUserID, BuzzUserArtID) VALUES
(@p0_0, @p1_0)
INSERT INTO BuzzUserFavourites (BuzzUserID, BuzzUserArtID) VALUES
(@p0_1, @p1_1)

It seems inefficient to me. What am I doing wrong ?

Thanks



--~--~---------~--~----~------------~-------~--~----~
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