But are updates to the <join>ed properties persisted? On Thursday, March 15, 2012 9:34:42 AM UTC, Oskar Berggren wrote: > > The sum it up, the problem is that you have a many-to-many relation on > one side, but want it to be a one-to-many on another side. > > Using the <join> element to treat CompanyToDocument and Document as > both being part of the Document entity sounds like a way forward. > > /Oskar > > > 2012/3/14 jksoft <[email protected]>: > > First off, I am relatively new to NHibernate and so far finding good > > documentation has been a trial. > > > > I am in the processing of using NH to connect to a legacy application > which > > also includes some new tables we are adding for this project. The > database > > makes extensive use of join tables to link two entities together. An > > example would be > > > > Company --> CompanyToDocument <-- Document > > CompanyToDocument > > - companyId > > - documentId > > > > While this is a traditional way of doing Many to Many relationships, it > > really is a One to Many as each Document can only be associated with one > > Company. > > > > I have been racking my brain trying to figure out how to model this in > the > > application and use NH to map appropriately. I really want my Document > > class to either have a "companyId" property or a Company property, not a > > collection of Companies which is the natural mapping for a Many to Many. > > > > One idea I came up with was to put both a Company and a Companies > property > > on my Document class so the NH Many to Many association would work. The > > problem with this is I still can't do a query using my companyId property > > since NH doesn't know anything about it. One thought I had is to use a > Join > > association to map the companyId property. I suppose another thought > would > > be to tweak the query to join back to the Join table. > > > > I wanted to seek out some advice as the pieces just don't seem to be > fitting > > in place which makes me think I must be doing something wrong here. > > > > I am open to any and all ideas here as I am stumped on this. > > > > Thanks for any advice, > > > > J > > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/nhusers/-/x8eTnz-LzOUJ. > > 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. > >
-- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/I_P3iM0rrCkJ. 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.
