Remove all specification about "lazy" and "fetch" from your mappings.For who
are new in NH the best way is :
-write your mapping specifying less as possible; string length when is
different than 255, scale+precision for double, after that write only what
is required.
-study how work with eager loading trough HQL and/or CriteriaAPI

When your app is working:
Go to reference and study "Improving performance"

Take a look to this mapping

<class name="OrdenDeCompra">
<id name="Id">
<generator class="hilo"/>
</id>
<many-to-one name="EmpresaCompra"/>
<many-to-one name="OrganizacionCompra"/>
<property name="Comentarios"/>

<property name="Numero" length="35"/>
<property name="Nombre" length="50"/>
<property name="Usuario" length="30"/>
<property name="FechaCreacion"/>
<property name="FechaEnvio"/>
<property name="FechaPublicacion"/>
<property name="Estado"/>
<many-to-one name="Moneda"/>
<many-to-one name="MetodoDespacho"/>
<many-to-one name="FormaPago"/>
<many-to-one name="RazonSocial"/>
<many-to-one name="EmpresaVenta"/>
<many-to-one name="OrganizacionVenta"/>
<list name="Lineas" access="field.camelcase" cascade="all" inverse="true">
<key column="IDOC" on-delete="cascade"/>
<list-index column="NUMLINEAOC"/>
<one-to-many class="OrdenDeCompraLinea"/>
</list>
</class>

heavy to write no ? ;)

2009/3/18 Fred F. <[email protected]>

>
> Hi folks!
>
> I'm using NHibernate v2.0.50727 and I'm quite uncertain about many-to-
> one and lazy loading, although I've read several blogs about this
> topic.
>
> I've got following scenario:
>
> Class A has a one-to-many relation to class B (bag collection) and B
> has got a many-to-one relation to class C. Class A an B do have some
> other many-to-one relations to other classes (lets say Relation R1 and
> Relation R2) which are not important for my query.
>
> Class A (1)--->(n) Class B (n) ---> (1) Class C
>
> Default is lazy=true, but I'm creating my criteria with an left outer
> join to the classes, so I only need one query for this case. I can see
> the correct query in my logs. This query returns a collection of
> records. I can test this query in my sql-client and everything is
> fine. So far so good.
>
> But:
>
> For _each_ of my records nhibernate sends additional queries to the
> database. And it seems that it queries for the related objects which
> are related to class A and B by many-to-one relations (Relation R1 and
> R2). This additional references are completely unnecessary in this
> case and they are not used in this part of the application.
>
> My question:
>
> Why is nhibernate quering for these additional objects although nobody
> uses them? I've tried several different options in my many-to-one
> relations like
>
> outer-join="false"
> lazy="proxy" (I suppose I'm not aware of the effect)
> fetch="select"/fetch="join"
>
> I've added lazy="false" to all classes.
>
> How can I prevent nhibernate to load these not needed objects? It has
> quite an impact on my performance level.
>
> Thanks in advance!
> Fred F.
>
> >
>


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