lazy-loading

Programmatic control of the Delay Loaded property in LINQ to SQL

Using LINQ to SQL, is there any way to specify "Delay Loaded = true" for some properties on entities using code? I can do it manually in the designer but I will lose that customization if the table is updated/rebound. I know of DataLoadOptions and LoadWith(), but that's for using eager loading instead of lazy loading, and I want to spe...

When does lazy loading become a problem in RIAs?

So I've got a simple web application using Spring MVC + Hibernate and am using the OpenSessionInViewFilter. I've recently been thinking of replacing the UI with something like Flex or GWT. At first I thought it would be easy, in that I can just hit my service layer from the new front end. But as I consider this a bit more, I'm a littl...

How to lazy load a one-to-one composition via hql

If have an entity A with a bidirectional one-or-zero-to-one mapping with entity B. The mapping is as follows: <class name="EntityA" table="TABLE_A" mutable="true" lazy="true"> <id name="idA" type="long" column="pk_a" unsaved-value="null"> <generator class="sequence"> <param name="sequence">pk_a_seq</param> ...

Finding the right pattern for loading objects with different graphs

I'm trying to figure out the best way to handle loading objects with different graphs (related entities) depending on the context their being used. For example Here's a sample of my domain objects: public class Puzzle { public Id{ get; private set; } public string TopicUrl { get; set; } public string EndTopic { get; set; } ...

NHibernate session management and lazy loading

I am having a heck of a time trying to figure out my session management woes in NHibernate. I am assuming that a lot of my trouble is due to lack of knowledge of IoC and AOP concepts; at least that is what I am thinking by where Fabio Maulo keeps directing me. Anyways, my problem is that I have a win forms application that is making "ge...

NHibernate's criteria.List() hangs when lazy property exists on entity

I've been getting some extremely bizarre behaviour where NHibernate queries start to hang. I've made a demo project that exhibits this behaviour in a repeatable fashion. You can download the project here Here's the offending code: public IList<Post> GetLatestLiveBlogEntries(int numEntriesToRetrieve) { var maxDate = Dat...

Persisting Lazy Loaded Properties

I am using a simple repository pattern and have objects with a LazyList such as: public class Promotion { public int Id { get; set; } public string Name { get; set;} public LazyList<Site> TargetSites { get; internal set; } // implemented as a LazyList } This works great for getting the items but I'm wondering what is usual...

Can I tell VS2008 to ignore debug-time evaluation of my lazily loaded properties?

In our .Net application, some of our business objects use lazy loading to access data from the server. While debugging, if I want to inspect a property I have to be very careful and not "look at" or access those properties because this causes the IDE to try and evaluate those properties, which fails. Is there an attribute I can put on ...

How can I access lazy-loaded fields after the session has closed, using hibernate?

consider this scenario: I have loaded a Parent entity through hibernate Parent contains a collection of Children which is large and lazy loaded The hibernate session is closed after this initial load while the user views the Parent data The user may choose to view the contents of the lazy Children collection I now wish to load that col...

Entity Framework: Issue with lazy load "solution" (Not asking how to do lazy loading)

So basically I came up with a semi home grown solution to lazy loading by basically having generated property be private and have a public property that dealt with whether to load the generated property: public ChatRoom ParentRoom { get { if(!ParentRoomInnerReference.IsLoaded) { ParentRoomInnerReference.Load();...

Lazy loading relationships in Django (and other MVCs/ORMs)

Interested in knowing how lazy loading is achieved in frameworks like Django. When is the decision made to perform the join? And is there a way to force eager loading in Django? Are there times when you would need to force Django to eager load? ...

Linq does not lazy load if invoked via generic method?

so, i have a method: I'm counting a number in a sequence with holes, this number should be the first hole or max() public static int GetRegisterNumber<T>(this IQueryable<T> enumerable, Func<T, bool> whereFunc, Func<T, int?> selectFunc) { var regNums = enumerable.OrderBy(selectFunc).Where(whereFunc).ToArray(); i...

LINQ to SQL Deferred Loading

DBML I have the following entities in my dbml: (made up for an example) Book <- Media -> AuthorsForMedia <- Author The arrows are the relationships in my dbml. A book is a type of media, and an instance of a book has a media property with the values common to all media in it. AuthorsForMedia is an intersecting table with an AuthorI...

Lazy loading with NHibernate Castle Facility

Do I have to close the ISession's that are generated by Castle's ISessionManager for NHibernate? How do I handle transactions with those ISession's? I'm still quite new to NHibernate. Edit: I would like to have lazy loading but I get this message: Initializing[failed to lazily initialize a collection of role: , no session or ses...

How to implement a Lazy List using SmartGWT and SQL

Hey all, I was trying all of yesterday to try and integrate a SQL Database with SmartGWT for a lazy list but I just couldn't figure out how to implement it. (JavaDoc, and example of a lazy list) What I want to do is create a list of a bunch of "sites" all over the world. The problem is there will probably be about a million of them, s...

NHibernate.LazyInitializationException

We have been having this issue pop up sporadically, but now I can reproduce it every time. I am incrementing a view counter on my custom built forums, which causes an error: NHibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed This error occurs on another collection in ...

Unreliable Hibernate Objects

I've run into a situation where the Hibernate object passed back from the query is unreliable. Consider the following code: MyClass myClass = myDAO.get(id); myClass.getId(); //This works myClass.getName(); //This returns null sometimes, and works sometimes Here's my get Method: @SuppressWarnings("unchecked") public T get(ID id) { ...

In Spring with jpa/hibernate, how do I keep a session open to avoid lazy initialization exceptions?

I currently mark collections in entity beans as eager to avoid getting a lazy initialization exception when I try to access the collection properties after loading the bean with the EntityManager. If I instead leave the collection as lazy loading, how do I keep a session open? I thought about trying @Transactional, but even if that work...

I’m not sure whether lazy load pattern is useful here

Hello, I’m currently reading a book on website programming and author mentions that he will code DLL objects to use lazy load pattern. I think that conceptually I somewhat understand lazy load pattern, but I’m not sure if I understand its usefulness in the way author implemented it BTW - Here I’m not asking for usefulness of lazy loa...

If SqlDatareader fetches one record at a time, and not one field at a time, then lazy load pattern wasn’t…

Hello, Does SqlDataReader fetch one record at a time from DB or one field at a time? Assume the following query returns a single row: select columns_1, column_2, column_3 from some_Table and suppose readerS ( readerS is an instance returned by SqlCommand.ExecuteReader() )only reads *column_3* before closing the connection: ...