I have to agree with snicker, that it should be possible to apply filters on many-to-one, and that the integrity of the model should be the responsibility of the developer. I have no problem with the framework making it hard to shoot yourself in the foot by making these filters "hard" to turn on, but at least it should be possible.
We are investigating using nhibernate to implement (map) a bi-temporal database. Our initial thoughts is to set up relationships using business (or surrogate) keys, and not use PK-FK relationships. This means accepting a few pains: RDBMS cannot enforce referential integrity (not to speak of temporal ref-integrity), so this must happen in sprocs/triggers, It also means using "property-ref" in mappings. None of these seem to be considered "kosher" by the community. However the tradeoff we must consider is accepting these "smells" in return for having the goodies of nhibernate in a bi-temporal database setting, versus building the app without an ORM (or even worse attempt to build ORM type functionality ourselves). PS. It seems that snicker has done the exact same analysis and wish to map a temporal database using nhibernate. Again, IMHO the developer/architect must be allowed to make those decisions himself, not the framework. An alternative of course is to look to EF4 (not sure what the story is there), or to branch off nibernate and either attempt to build support for this ourselves (most likely we would need to hire/sponsor an NH expert since messing with the NH internals will bring us firmly outside our comfort zone). -- Thor A. Johansen R&D Manager Oppad AS On 18 Mar, 18:51, snicker <[email protected]> wrote: > Why do I *need* an explicit join? If a filter can be applied to a one- > to-many collection, why cannot the same functionality be available for > a many-to-one?? > > I can lazily load a collection with a filter, why will NHibernate > *NOT* let me do this with a many-to-one? I have heard you say that > this does not guarantee the integrity of the model. It is the > responsibility of the user to ensure that *their* explicit > configuration ensures the integrity of the model. I have several many- > to-one fields on each of my entities that require this filter.. I > cannot join on all of them simultaneously when loading the entity. > > Currently I have to resort to a hack such as this to get the desired > functionality: > > public virtual MyClass ReferencedManyToOneObject { > get { ListHack.Count > 0 ? ListHack[0] : null; } > set { ListHack[0] = value; }} > > public virtual IList<MyClass> ListHack { get; set; } > > And then I map ListHack as a many-to-one with the filter. THIS GETS MY > DESIRED RESULTS! But as you can see it is nothing more than a > completely dirty filthy hack and it makes me incredibly uncomfortable. > I simply wish to be able to apply a filter to many-to-one > relationships JUST as one can with one-to-many. > -- 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.
