eager-loading

LINQ to SQL eager loading with conditions

I'm trying to learn LINQ to SQL and i've found out about the LoadWith function. All the examples i've found will load all records from the table you specify in the LoadWith function e.g. var dlo = new DataLoadOptions(); dlo.LoadWith<Blog>(b => b.Posts); this.LoadOptions = dlo; What I would like to know is if it's possible to load in t...

Loading Complete graph from Sql using LINQ

Assume we have a Menu class that has SubMenus (which is the same type of Menu therefore can have SubMenus and Items too) and Items (which has a different type) and we stored them in two tables(One for Menus and one for Items). Is there any way to load complete graph of the Menu class (all of its SubMenus and Items) using LINQ to SQL? ...

Updating eager-loaded associations in memory

In my current rails app I'm pulling a lot of data from the database into memory so that I can start a long-running background task that I don't want to hit the database every 5 seconds. This is all working great but I have some inelegant code that I'd like to get rid of if possible. For an example, I have the situation where I have a U...

Using Fluent NHibernate's AutoPersistenceModel but with eager loading in a single object

I'm using Fluent NHibernate in order to auto map my entities. This is the code I'm using for the auto mapping: new AutoPersistenceModel() .AddEntityAssembly(Assembly.GetAssembly(typeof(Entity))) .Where(type => type.Namespace.Contains("Domain") && type.BaseType != null && type.BaseType.Name.StartsWith("DomainEntity") && type.BaseTyp...

Eager loading not working in Rails 2.2.2

I'm working with models analogous to the following: class Owner < ActiveRecord::Base has_many :owned end class Owned < ActiveRecord::Base belongs_to :owner end You can presume that owned_id and owner_id are in the right places. The trouble is that, in a controller for a different mvc chain in the app, @owner = Owned.find_by_id(...

How to get an eager loaded conditional to be lazy loading later on with ActiveRecord and Rails

First let me show some code. class User has_and_belongs_to_many :roles named_scope :employees, { :conditions => ["roles.name = 'Employee'"], :include => :roles } end OK, so later in a controller I wanted to search for all the employees right. I set the named scope up to help do that with the join and conditional search. But the pr...

LINQ to Entity Framework Eager Loading issue

I have the following query: var MyQuery = from e in ContractContext.Equipments.Include("Manufacturers") where e.Customers.ID == customer.ID select e; And everything works, I get my Equipments and it loads the Manufacturers table correctly (eagerly). But when I try to do the following many-to-many query: v...

Eager loading child collection with NHibernate

I want to load root entities and eager load all it's child collection and aggregate members. Have been trying to use the SetFetchMode in FluentNHibernate, but are getting duplicates in one of the child collection since I have a depth of 3 levels. DistinctRootEntityResultTransformer unfortunately only removes the root duplications. ret...

Eager Loading aggregate roots with Entity Framework

I would like to create a more structured approach to loading the needed entity-tree: I need a serious amount of data, so I'm doing this using type-safe Includes (just a normal Include but with Lambda's) as shown here. As I said, I need a lot of data, basically a whole entity tree under 1 parent item. Now, I could do this doing somethi...

How do I test the NHibernate FetchMode.Eager properly?

Is there any way to write an integration test to test that the FetchMode.Eager works correctly? I want to verify that it's not going to the database when I retrieve MySubObject. The code: public MyObject GetEager(string name) { return Session .CreateCriteria(typeof(MyObject)) .SetFetchMode("MySubObject", FetchMode....

Rails: How do I minimize DB hits here? Eager loading isn't applicable

Hi, this question is maybe a little specific, but I think it's interesting from a general pov also. In a Rails App users can subscribe to other users. When I show a list of users I have to check, if the current user has subscribed to the users in the list. If he has subscribed, I show the unsubscribe button and the other way around. B...

Rails eager loading, possible bug

In my Rails 2.3.2 app I have 2 models: class Post has_many :approved_comments, :class_name => 'Comment', :conditions => ['approved => ?', true] end class Comment belongs_to :post end For some reason when I try to eager load my comments, I get an error post = Post.find(:first, :conditions => ["permalink=?", permalink], :includ...

Eager loading vs. many queries with PHP, SQLite

I have an application that has an n+1 query problem, but when I implemented a way to load the data eagerly, I found absolutely no performance gain. I do use an identity map, so objects are only created once. Here's a benchmark of ~3000 objects. first query + first object creation: 0.00636100769043 sec. memory usage: 190008 bytes itera...

Why lazy instantiation of the MessageResourcesFactory in Struts 1.2.7?

Hi, Since there is the Double-checked locking issue so we have to use synchronization to guarantee the concurrent access to the following method (org.apache.struts.util.MessageResources class) : LAZY INSTANTIATION public synchronized static MessageResources getMessageResources(String config) { if (defaultFactory == null) { ...

Eager loading of Linq to SQL Entities in a self referencing table

I have 2 related Linq to SQL questions. Please see the image below to see what my Model looks like. Question 1 I am trying to figure how to eager load the User.AddedByUser field on my User class/table. This field is generated from the relationship on the User.AddedByUserId field. The table is self-referencing, and I am trying to figu...

Strategic Eager Loading for many-to-many relations in Datamapper?

I'm using DataMapper, an open source ORM for ruby, and I have in itch I would like to scratch. At the moment, DataMapper can use Strategic Eager Loading(SEL) for one-to-many relationships, but not many-to-many, where N+1 queries occur. I would like to hack around with making this work correctly, but I cannot find where to do it. So tw...

Eager loading child and child-of-child collections in NHibernate

I've got a problem with NHibernate trying to load a small hierarchy of data. My domain model looks like: class GrandParent { int ID{get;set;} IList<Parent> Parents {get; set;} } class Parent { IList<Child> Children {get; set;} } class Child { } and I would like to eager load all parents and children for a given GrandPar...

Eager Loading with Many-to-Many relationship - Grails (GORM)

Each book can have many authors. And each author can author many books. class Book { static belongsTo = Author static hasMany = [authors:Author] } class Author { static hasMany = [books:Book] } Now when can I do: def book = Book.get(id) def authors = book.authors Now I am thinking I should be able to take each author and ...

How to Determine if Rails Association is Eager Loaded?

Does anyone know a way to determine if a Rails association has been eager loaded? My situation: I have a result set where sometimes one of the associations is eager loaded, and sometimes it isn't. If it isn't eager-loaded, then I want to look up associations using ActiveRecord's find. If it is eager loaded, I want to use detect. ...

Eager loading in Entity Framework fails on complex query

The following query fails to load the tables when I execute it: IEnumerable<Bookmark> tempBookmarks = ListBookmarksByUserID(userID); IEnumerable<CandidateWithBookmarks> results = (from c in _internshipEntities.CandidateSet .Include("education") .Incl...