There's two major options. Either you leave it as one to many, or you make it a many to many. As a one to many, you end up with flags on the child table. As a Many to Many, you can either have flags on the joining table, or you can have multiple joining tables. One option will probably make more sense, depending on what your rules are - for example, can a single instance of the child object appear in more than one list? That said, you won't be able to infer these rules simply by examining the domain object structure.
On Thu, Dec 17, 2009 at 7:35 PM, cliff vaughn <[email protected]>wrote: > Just curious, can someone show the other ways of mapping this that would > work well in FNH? > > > On Wed, Dec 16, 2009 at 10:00 PM, James Gregory > <[email protected]>wrote: > >> I agree entirely. I was just trying to be polite. >> >> >> On Wed, Dec 16, 2009 at 9:57 PM, Paul Batum <[email protected]> wrote: >> >>> Would we? >>> >>> To be honest I'm skeptical about whether the extra complexity would be >>> worth it in this case. Especially considering that there are multiple ways >>> in which this scenario can be handled in terms of relational db schema... >>> >>> In my opinion, if people really want to approach the implementation of >>> their application with "all I care about is my object model, I don't want to >>> have to think about persistence" attitude, maybe they should be looking at >>> an object oriented database such as db4o <http://www.db4o.com/>. Working >>> with NHibernate makes persistence easy, but I still have to think about my >>> relational model and how I want it mapped. Fluent NHibernate makes the >>> configuration of NHibernate even easier, but still, *I expect to have to >>> think about my relational model and how I want it mapped*. >>> >>> Paul >>> >>> >>> >>> >>> On Thu, Dec 17, 2009 at 7:46 AM, James Gregory <[email protected]> >>> wrote: >>> > I was going to write a long winded reply concerning your design >>> decisions, >>> > but I think it can more easily be summed up as: >>> > If it hurts, don't do it. >>> > You're the first person in the life of FNH to need to do this, that >>> should >>> > raise alarm bells. >>> > We'll gladly accept a patch to support this behaviour, but I don't >>> think >>> > implementing it will be an easy task. >>> > On Wed, Dec 16, 2009 at 8:22 PM, tbushell <[email protected]> wrote: >>> >> >>> >> >>> >> On Dec 15, 11:19 am, kimsk112 <[email protected]> wrote: >>> >> > I am sorry to hijack this thread. I just wonder why you don't use >>> Many- >>> >> > To-Many (i.e., create an association table) to differentiate between >>> >> > those lists? Is the above method (i.e., extra property in the class) >>> >> > better way to do this? >>> >> >>> >> My sample code was based on the "Examples.FirstProject", which I >>> >> hacked just enough to demonstrate the problem. You, Hudson and Paul >>> >> all raise valid points about the flaws in the design. But maybe my >>> >> choice of sample code is clouding the issue a bit. >>> >> >>> >> Also, I chose to use NHibernate because I wanted to do a pure, Object >>> >> Oriented data model, without being distracted and contrained by the >>> >> minutae of the underlying DB - like which tables get mapped to which >>> >> classes, how the relationships are set up, etc. (I realize now I was >>> >> a bit naive, but ideallly, that's still the way I'd like to approach >>> >> it). >>> >> >>> >> Here's the actual class I needed to map: >>> >> >>> >> public class DlsAppOverlordExportRunData >>> >> { >>> >> public virtual int Id { get; private set; } >>> >> >>> >> public virtual DateTime StartDateTime { get; set; } >>> >> // ... other members omitted for clarity ... >>> >> >>> >> public virtual IList<DistributionResults> >>> >> LogNormalDistributionTable { get; set; } >>> >> >>> >> public virtual IList<DistributionResults> >>> >> ContinDistributionTable { get; set; } >>> >> >>> >> public virtual IList<DistributionResults> >>> >> NnlsDistributionTable { get; set; } >>> >> >>> >> // ... >>> >> } >>> >> >>> >> As you can see, this class has 3 lists of DistributionResults >>> >> objects. I firmly believe this is a good object model for our problem >>> >> domain (a scientific instrumentation application). >>> >> >>> >> I also believe that it is not unreasonable to have multiple lists of >>> >> the same type in a class, and was very surprised that Automapping did >>> >> not handle it. Surely I'm not the first person who's wanted to do >>> >> this? >>> >> >>> >> Solution is not that hard, once you know the "trick". I just added a >>> >> SubId member to the classes I needed to do Where overrides on, but it >>> >> seems like a bit of a kluge. >>> >> >>> >> How hard would it be to make this work automatically in Fluent >>> >> Nhibernate? >>> >> >>> >> -Tom >>> >> >>> >> -- >>> >> >>> >> You received this message because you are subscribed to the Google >>> Groups >>> >> "Fluent NHibernate" group. >>> >> To post to this group, send email to >>> [email protected]. >>> >> To unsubscribe from this group, send email to >>> >> [email protected]<fluent-nhibernate%[email protected]> >>> . >>> >> For more options, visit this group at >>> >> http://groups.google.com/group/fluent-nhibernate?hl=en. >>> >> >>> >> >>> > >>> > -- >>> > >>> > You received this message because you are subscribed to the Google >>> Groups >>> > "Fluent NHibernate" group. >>> > To post to this group, send email to >>> [email protected]. >>> > To unsubscribe from this group, send email to >>> > [email protected]<fluent-nhibernate%[email protected]> >>> . >>> > For more options, visit this group at >>> > http://groups.google.com/group/fluent-nhibernate?hl=en. >>> > >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Fluent NHibernate" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<fluent-nhibernate%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/fluent-nhibernate?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Fluent NHibernate" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<fluent-nhibernate%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/fluent-nhibernate?hl=en. >> > > > > -- > thanks > > cliff > > -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<fluent-nhibernate%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en. > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en.
