The requirement to separate the entities into different assemblies comes from a layered domain model.
I should be able to use an order management model with its entities (order, line item etc) from an invoicing model (invoice, etc) with the restriction that the dependent assembly (order management) must not be changed. Given the situation, I outlined above - the relationship can only be uni-directional. ie. The relationship can be traversed from the Invoice to the Order. but not in the other direction. This gets tricky because the relationship can only be modeled as a many-to-many, since the Order entity/table cannot be modified, even though the actual requirement might be a One-To-Many relationship between Invoice and Order. So the problem boils down to two cases: (1) The dependent assembly can be modified to create a bi-directional relationship (2) The dependent assembly cannot be modified to create a uni- directional relationship. Just wondering if others have run into this kind of an issue and if so what patterns have they used to solve the problem. Thanks. Sudip On Sep 30, 11:33 am, Oskar Berggren <[email protected]> wrote: > In the general case, your one-to-many relationship don't have to be > "visible" in both A and B. > > Another thing to consider is if the classes really belong in different > assemblies if they _must_ now about each other. > > I cannot speak about your idea with interfaces, haven't used that in > the way you seem to be thinking about. > > /Oskar > > 2009/9/30 sudip <[email protected]>: > > > > > I have the following situation: > > > Assembly A.dll contains entity A and its mapping file A.hbm.xml > > Assembly B.dll contains entity B and its mapping file B.hbm.xml > > > I want to create a One-to-Many relationship between A and B ( A has > > many B's). > > > What is the recommended way for doing this? Obviously, I can't add a > > reference to B in A.dll and vice versa because that would cause a > > circular dependency. > > > Is it possible to do the following: > > > A derives from interface IA > > B derives from interface IB > > > IA and IB are put in a common assembly (Common.dll). > > A.dll specifies the collection element as IB in mapping and code > > B.dll specifies the parent as IA in mapping and code > > > Use dependency injection via a container to tell NHibernate to use B > > when it sees IB and A when it sees IA. > > Not sure how the dependency injection would be specified to > > NHibernate. > > > Looking forward to some responses. > > Thanks. > > > Sudip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
