--
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 nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
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 <jer...@digiwebstudios.com>:
Hi,
One way for doing this is to use the documentid as a primary key(or apply a unique constraint) in the CompanyToDocument table so that it shares a one-to-one relationship with Document table.
I think the OR Map too is clear in this case.
Regards
Surya
On Thu, Mar 15, 2012 at 2:34 AM, jksoft wrote:
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 beCompany --> CompanyToDocument <-- DocumentCompanyToDocument- companyId- documentIdWhile 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 nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.
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 :