Personally, I would have used "fetch" to refer to any database retrieval. My use of "cascade" referred to the specific aspect of collecting the associations. However, I am a student here and appreciate your correction.
"Smells!" Ouch - though I deeply appreciate the feedback. I've written a static class, Orm, to manage a single session available to any software that needs it during this browser visit. Using "HttpContextAccess.getSessionVariable" allows me to store the session so that I can avoid recreating it if a different method executes startSession(). You say there are better patterns out there. Would you mind pointing me at something that whose smell is a little more beautiful? In any case, the inclusion of the Orm.startSession() is an error. But, it has no effect since the routine sees that a session has already been created and does nothing. I do startSession() in the controller that calls the model method I showed here. That's where the missing close is as well. All of which is to say that it appears that, despite the anomalies, I gather that you don't see any reason that I _always_ get the subordinate associations. That said, can you make any suggestions about how I can try to debug this? I have situations in my near future where this problem will try to bring a thousand or more extra objects into being against my will. As always, I can't thank you enough for the help here. We still need to figure out how to do international remote-control cocktails. peace, tqii ps, I use the funny query syntax at the moment because I can easily edit it to do different things. In the future, there will only be one record in that table and the query adjusted to reflect that fact. pps, I'm actually a PHP guy dropped kicking and screaming into .NET. Thankfully, I was able to switch to MVC.NET (a billion times better). Visual Studio uses a different case standard so I am presently inconsistent, sometimes PHP, sometimes .NET. Truth is, I haven't exactly figured out what .NET wants. If you can point me at a reference that explains the .NET way of naming things, I'd be grateful. On Jun 10, 7:11 pm, Diego Mijelshon <[email protected]> wrote: > Yeah... that too :-D > > Diego > > > > On Thu, Jun 10, 2010 at 20:12, Fabio Maulo <[email protected]> wrote: > > Diego. > > In that "pattern", did you see a session close ? > > > On Thu, Jun 10, 2010 at 6:03 PM, Diego Mijelshon > > <[email protected]>wrote: > > >> 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%252bunsubscr...@googlegroup > >>> s.com>> > >>> > > . > >>> > > 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]<nhusers%[email protected] > >> > > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/nhusers?hl=en. > > > -- > > 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]<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.
