All, Thanks for the help. I was able to find a workaround for my issue.
Here's what I had originally : 2 classes mapped to each other through an intermediate class. The intermediate class persisted to an associative table. Photo ==> (one-to-many)==> TagNameValue Tag ==> (one to many) ==> TagNameValue Here's what I modified it to (which worked) 2 classes mapped to each other via many-to-many (allowing nhibernate to auto-generate the associative table) and 1 separate many-to-one table (where cascade is turned off) Photo ==> (many-to-many) TagValue TagValue (many-to-one) ==> Tag Basically, I was trying to store some data on the intermediate associative table. For the workaround, I broke out the data into a separate table so that NHibernate could auto-generate a regular many- to-many associative table. Then, to avoid my error, I turned off cascading-updates on the Tag table. Thanks for the feedback, -Neo707 On Apr 23, 1:19 pm, neo707 <[email protected]> wrote: > Hello, > > I'm new to NHibernate but learning quickly. I'm stuck on an issue and > I was hoping you could help me out... > > Here's my scenario : > > I have 3 Classes participating in a many-to-many relationship through > an intermediate association. > > 1.) Class Photo (key=PhotoID): a class representing a photo; it has a > one-to-many relationship with TagValue > 2.) Class TagValue (fkeys=PhotoID,TagID): an intermediate class/ > association with a many-to-one relationship with both Blog and Tag. > 3.) Class Tag : a class representing a tag that someone might assign > to a photo. The Tag is special in that it can have a value in > addition to a name; Tag has a one-to-many relationship with TagValue; > > The Photo class has a one-to-many relationship with TagValue. > > When I try to do Session.SaveOrUpdate(Photo), I get the following > error message : > "Unable to add photo. Error: a different object with the same > identifier value was already associated with the session: 1, of > entity: Tag" > > This error occurs when I have multiple tags (with the same text but > different value)) associated to the same Photo. > > Thanks for your help, > -Neo707 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
