Thanks so much, Anne. Using many-to-many solved the issue, a bit concerned about the drawbacks you mentioned, but it works fine for now.
Thanks, On 15 May, 23:59, Anne Epstein <[email protected]> wrote: > Sure, no problem using a many-to-many with no AnalystWorkAgreement > entity if those are the only two columns you're going to have in > AnalystWorkAgreement. I'll note that things often creep into the > many-to-many-tables (a hypothetical example in this case might be a > AnalystRoleForAgreement property) . In that case, you'll need to make > AnalystWorkAgreement its own entity, and have many-to-one > relationships out of it, and have bags all around into it (but regular > bags, not many-to-many bags) > > Good luck! > > On Fri, May 15, 2009 at 9:34 AM, [email protected] > > <[email protected]> wrote: > > > Hi, > > > I'm trying to map 5 tables to my domain model : > > > Person {PersonID} > > Analyst {AnalystID, PersonID} > > WorkAgreement{WorkAgreementID, CompanyID} > > Company{CompanyID} > > AnalystWorkAgreement{WorkAgreementID, PersonID} > > > So far I have mapped Person, Analyst, WorkAgreement and Company. But I > > can't figure out how to map AnalystWorkAgreement. > > > here's the mapping for Person and Analyst (note that Analyst is a > > subclass of Person) : > > > <class name="Comp.Person, Comp" table="Person"> > > > <id name="Id" column="PersonID"> > > <generator class="identity"/> > > </id> > > > <!-- Description of an analyst entity --> > > <joined-subclass name="Comp.Analyst, Comp" table="Analyst" > > lazy="true"> > > <key column="PersonID"/> > > > </joined-subclass> > > > </class> > > > The mapping for WorkAggreement : > > > <class name="Comp.WorkAgreement, Comp" table="WorkAgreement" > > lazy="true"> > > <id name="Id" column="WorkAgreementID"> > > <generator class="native"/> > > </id> > > > <many-to-one name="theCompany" class="Comp.Company, Comp" > > column="CompanyID"/> > > </class> > > > I have not included the mapping for Company as it's quite obvious. > > > Now I should I map AnalystWorkAgreement? It's meant to be a collection > > of WorkAgreements in the Analyst class so I guess somehow the table > > should be mapped as a many-to-many property maybe ? I don't think I > > should create class for it but ideas are welcomed. > > > Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
