from A a join fetch a.Bs

2009/3/15 Thomas Koch <[email protected]>

>
> We are currently mapping a legacy database, into a domain model using
> NHibernate as the ORM.
>
> One of the domainobjects A has a changelog where each entry is B. I do
> not normally use the changelog for anything so I do not want A to load
> the changelog entries eagerly. But when I do use them I want to avoid
> select n+1, hence my question.
>
> The problem might be that I should have chosen to model this
> differently. I could have dropped having NH manage the connection
> between A and B and simply regarded B as an entity on its own. So
> maybe this really boils down to "when should you use NH to map an
> association between entities".
>
> Thomas
>
>
>
> On 15 Mar., 12:07, Tuna Toksoz <[email protected]> wrote:
> > for what purpose do you use A?
> > What I would do would be to take enough amount of A(via paging) and
> assume I
> > will need all children of those A's so I eagerly fetch them.
> >
> > To say the truth, I didn't think of your scenario, it may be right or
> wrong,
> > but above is how I would do it.
> >
> > Tuna Toksözhttp://tunatoksoz.comhttp://
> devlicio.us/blogs/tuna_toksozhttp://twitter.com/tehlike
> >
> > Typos included to enhance the readers attention!
> >
> >
> >
> > On Sun, Mar 15, 2009 at 1:02 PM, Thomas Koch <[email protected]> wrote:
> >
> > > Hi Tuna - ok. I will definitely use the batching feature.
> >
> > > Our little dialoge got me thinking again, so now I have created  a
> > > generic "Initialize(object)" method on DAO interface, which in turn
> > > invokes the NHibernateUtil.Initialize(object) method.
> >
> > > My domain objects know about DAO interfaces so whenever I feel like it
> > > I can invoke this method to ensure my collections are fully loaded,
> > > without having the NHibernate classes leak into my domain.
> >
> > > Regards
> > > Thomas
> >
> > > On 15 Mar., 10:09, Tuna Toksoz <[email protected]> wrote:
> > > > Then I believe the link with batching will help ;)
> >
> > > > Tuna Toksözhttp://tunatoksoz.comhttp://
> > > devlicio.us/blogs/tuna_toksozhttp://twitter.com/tehlike
> >
> > > > Typos included to enhance the readers attention!
> >
> > > > On Sun, Mar 15, 2009 at 1:15 AM, Thomas Koch <[email protected]>
> wrote:
> >
> > > > > Hi Tuna - thanks for the link.  :)
> >
> > > > > It makes me nervous though when you write that. What is it that is
> > > > > nagging you? Is this not a normal approach?
> >
> > > > > Would you rather have me do a: NHibernateUtil.Initialize(A.Bs)
> >
> > > > > A few details about my setup. We are using NH 2.0 in an ASP.NETapp.
> > > > > We use the open-session-in-view pattern with the DAO pattern to
> load
> > > > > our entities. Each DAO class have a corresponding interface, thus
> no
> > > > > NHibernate details are leaking into the rest of the application.
> >
> > > > > Thomas
> >
> > > > > On 15 Mar., 00:04, Tuna Toksoz <[email protected]> wrote:
> > > > > > section 14.3
> >
> > > > > >
> http://www.hibernate.org/hib_docs/nhibernate/html/performance.html
> >
> > > > > > But what you're doing doesn't sound right to me.
> >
> > > > > > Tuna Toksözhttp://tunatoksoz.comhttp://
> > > > > devlicio.us/blogs/tuna_toksozhttp://twitter.com/tehlike
> >
> > > > > > Typos included to enhance the readers attention!
> >
> > > > > > On Sun, Mar 15, 2009 at 1:00 AM, Tuna Toksoz <[email protected]>
> > > wrote:
> > > > > > > oh you mean batching then.
> >
> > > > > > > Tuna Toksöz
> > > > > > >http://tunatoksoz.com
> > > > > > >http://devlicio.us/blogs/tuna_toksoz
> > > > > > >http://twitter.com/tehlike
> >
> > > > > > > Typos included to enhance the readers attention!
> >
> > > > > > > On Sun, Mar 15, 2009 at 12:58 AM, Thomas Koch <
> [email protected]>
> > > > > wrote:
> >
> > > > > > >> As far as I understand it, the setup I am using will lead to
> > > select n
> > > > > > >> +1, when doing a foreach on the collection of B's. Please
> correct
> > > me-
> > > > > Skjul tekst i anførselstegn -
> >
> > > > > > - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
> >
> > > > - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -
> >
> > - Vis tekst i anførselstegn -
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to