Just map Organization et Culture with a many-to-one as per your tables, query like Fabio said and project into some dto using a result transformer or new it up in HQL.
Simon On Fri, Sep 4, 2009 at 1:41 PM, Lefty <[email protected]> wrote: > > I was going to try an implementation of command query separation. > This example would be from the query side. There would be two > different NH models, 1 supporting the domain on the command side, and > this other lightweight "domain" that simply maps database data to DTO > objects for use by the UI. > > After some further digging, my example may not be entirely valid, I > will likely require use of the Culture DTO at some future point. So > the proper way to model this would, I guess, be with a many-to-one > relation. > > However, assuming that was not the case, it is possible to map a > single DTO object to the database, where fields from the DTO come from > multiple tables AND the join is a foreign key (not a shared primary > key like the ones used by the component examples)? > > > > On Sep 4, 1:04 pm, Fabio Maulo <[email protected]> wrote: > > sorry... which is your domain ? > > > > 2009/9/4 Lefty <[email protected]> > > > > > > > > > > > > > Hi. For that query, I would have to create a Culture entity and map > > > it to DefaultCulture wouldn't I? > > > > > I was hoping for a way to just get the value I was looking for, > > > without creating a Culture entity. > > > > > On Sep 4, 12:52 pm, Fabio Maulo <[email protected]> wrote: > > > > select o.id, o.DefaultCulture.id, o.DefaultCulture.LCID from > > > Organization o > > > > > > 2009/9/4 Lefty <[email protected]> > > > > > > > Getting started with NHibernate, and this has stumped me. Consider > > > > > these tables. > > > > > > > Organization > > > > > ========== > > > > > OrganizationId (PK) > > > > > Name > > > > > DefaultCultureId (FK) > > > > > > > Cultures > > > > > =========== > > > > > CultureId (PK) > > > > > Name > > > > > LCID > > > > > > > When I map the Organization entity, I would like to have these > > > > > properties: > > > > > > > OrganizationId > > > > > Name > > > > > DefaultCultureId > > > > > LCID <== loaded from Cultures using the DefaultCultureId FK > > > > > > > where LCID is retrieved from Cultures, using the DefaultCultureId > (FK) > > > > > mapped to CultureId > > > > > > > I think I could create a Culture entity and have a Culture > property, > > > > > but I am trying to create a simple OrganizationDTO class with only > the > > > > > properties that the UI needs. > > > > > > > The closest I've come to getting this to work is with a <join> but > > > > > that loads the incorrect culture (uses OrganizationId for lookup > > > > > instead of the DefaultCultureId FK) > > > > > > > To me this is the simplest of joins, but NH seems to be making it > > > > > difficult. > > > > > > -- > > > > Fabio Maulo > > > > -- > > Fabio Maulo > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
