For retrieving associations, the term is "fetching".

With that mapping, NH should be retrieving the "First"* LEAInfo instance
only, and retrieve the schools only when you iterate the corresponding
collections.

Your query looks strange too. You are doing .Skip(0).Take(1).First(), which
is the same as .Skip(1).First()...

Also, the pattern you are using to create the session and factory smells a
little... I can't say it's wrong because I have no idea about the
implementation of HttpContextAccess.getSessionVariable. I suggest you take a
look at the many existing samples and patterns.
BTW, are you porting something from Java? (because of the camelCase method
names...)

*: you are not specifying an order, so "first" is whatever the database
decides is the first row

   Diego


On Thu, Jun 10, 2010 at 17:18, tqwhite <[email protected]> wrote:

> Do we use a different word than "cascade" to refer to the depth of
> associations retrieved? It seems a natural inverse of the usage when
> saving. Please advise.
>
> According to Visual Studio, I never use the word "lazy" in the entire
> project.
>
> The mapping file is below. Thank you very much for looking at it. I've
> already killed hours on this. I really need help.
>
> tqii
>
> <?xml version="1.0" encoding="utf-8" ?>
>
>        <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> assembly="DatabaseModel" namespace="DatabaseModel">
>
>          <class name="DatabaseModel.Models.LEAInfo, DatabaseModel"
> table="Districts" >
>                <id name="RefId" type="guid">
>                  <generator class="guid.comb">
>                  </generator>
>                </id>
>                <property name="LocalId" column="LocalId" type="string" not-
> null="false"/>
>                <property name="LEAName" column="LEAName" type="string" not-
> null="false"/>
>                <property name="LEAURL" column="LEAURL" type="string" not-
> null="false"/>
>
>                <bag name="schools">
>                  <key column="LEAInfoRefId"/>
>                  <one-to-many class="DatabaseModel.Models.SchoolInfo,
> DatabaseModel" />
>                </bag>
>          </class>
>
>          <class name="DatabaseModel.Models.StudentPersonal, DatabaseModel"
> table="Students">
>                <id name="RefId" type="guid">
>                  <generator class="guid.comb">
>                  </generator>
>                </id>
>                <property name="LocalId" column="LocalId" type="string" not-
> null="false"/>
>
>
>                <component name="Name"
> class="DatabaseModel.Services.BaseDataObjects.NameOfRecordType,
> DatabaseModel">
>                          <property name="FirstName"/>
>                          <property name="LastName"/>
>                </component>
>                <bag name="enrollments">
>                           <key column="StudentPersonalRefId"/>
>                           <one-to-many
> class="DatabaseModel.Models.StudentSchoolEnrollment, DatabaseModel" />
>                </bag>
>          </class>
>
>
>          <class name="DatabaseModel.Models.SchoolInfo, DatabaseModel"
> table="Schools">
>                <id name="RefId" type="guid">
>                  <generator class="guid.comb">
>                  </generator>
>                </id>
>
>                <property name="SchoolName" type="string" not-null="false"/>
>                <property name="LEAInfoRefId" type="string"
> not-null="false"/>
>
>                <bag name="enrollments">
>                          <key column="SchoolInfoRefId"/>
>                           <one-to-many
> class="DatabaseModel.Models.StudentSchoolEnrollment, DatabaseModel" />
>                </bag>
>          </class>
>
>
>
>
>          <class name="DatabaseModel.Models.StudentSchoolEnrollment,
> DatabaseModel" table="StudentSchoolEnrollment">
>                <id name="RefId" type="guid">
>                  <generator class="guid.comb">
>                  </generator>
>                </id>
>                <property name="SchoolYear" column="SchoolYear"
> not-null="false"/>
>                <property name="EntryDate" not-null="false"/>
>
>                <many-to-one not-null="false"
> class="DatabaseModel.Models.StudentPersonal, DatabaseModel"
> name="student" column="StudentPersonalRefId"/>
>                <many-to-one not-null="false"
> class="DatabaseModel.Models.SchoolInfo, DatabaseModel" name="school"
> column="SchoolInfoRefId" />
>
>          </class>
>
>
>        </hibernate-mapping>
>
>
> On Jun 10, 3:05 pm, Diego Mijelshon <[email protected]> wrote:
> > What are your mappings?
> > And what does this have to do with cascading?
> > Wild guess: you've set everything as lazy="false".
> >
> >    Diego
> >
> >
> >
> > On Thu, Jun 10, 2010 at 16:41, tqwhite <[email protected]> wrote:
> > > I cannot control the cascade depth. No matter what I do, NH retrieves
> > > the entire object graph and all associations. It stops at some level
> > > (there is recursion otherwise) though the data is too big and complex
> > > for me to analyze exactly where.
> >
> > > I am presently trying to set the depth to zero (I also tried one) in
> > > an attempt to get something recognizable to happen. It is not working.
> > > Can you see what I am doing wrong?
> >
> > > This method looks up the root object:
> >
> > >        public virtual LEAInfo getFirst()
> > >        {
> > >            Orm.startSession();
> >
> > >            var dbResult = (from testList
> > >                            in Orm.session.Linq<LEAInfo>()
> > >                            select testList)
> > >                            .Skip(0)
> > >                            .Take(1);
> >
> > >            LEAInfo outObj = dbResult.First<LEAInfo>();
> > >            return outObj;
> > >        }
> >
> > > Orm.startSession creates a static session. It works just like I expect
> > > it to when I am saving things. Note the use of max_fetch_depth:
> >
> > >        public static ISession startSession(){
> > >            if (HttpContextAccess.getSessionVariable("session") ==
> > > null)
> > >            {
> > >                Configuration config = new
> > > NHibernate.Cfg.Configuration()
> > >                    .SetProperty("max_fetch_depth", "0");
> > >                config.Configure();
> > >                ISessionFactory sessionFactory =
> > > config.BuildSessionFactory();
> > >                ISession newSession = sessionFactory.OpenSession();
> > >                HttpContextAccess.addSessionVariable("session",
> > > newSession);
> > >            }
> > >            return
> > > (ISession)HttpContextAccess.getSessionVariable("session");
> > >        }
> >
> > > Thanks for your help.
> >
> > > tqii
> >
> > > --
> > > 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]<nhusers%[email protected]>
> <nhusers%[email protected]<nhusers%[email protected]>>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

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