I have some objects:
Public Class Person() {
public int Id {get;set;}
public IList<Account> Accounts {get;set;}
public string Email {get; set;}
}
public class Account(){
public int Id {get;set;}
public IList<AccountPayment> Payments {get;set;}
public IList<Venue> Venues {get;set;}
}
public class AccountPayment(...
I'm a little confused as to the mechanics of eager loading in active record. Lets say a Book model has many Pages and I fetch a book using this query:
@book = Book.find book_id, :include => :pages
Now this where I'm confused. My understanding is that @book.pages is already loaded and won't execute another query. But suppose I want to ...
I have a simple @OneToMany between Person and Pet entities:
@OneToMany(mappedBy="owner", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
public Set<Pet> getPets() { return pets; }
I would like to load all Persons with associated Pets. So I came up with this (inside a test class):
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfig...
Consider the following Class structure...
public class ListViewControl
{
public int SystemId {get; set;}
public List<ControlAction> Actions {get; set;}
public List<ControlAction> ListViewActions {get; set;}
}
public class ControlAction
{
public string blahBlah {get; set;}
}
I want to load class ListViewControl eagerly...
HI,
I have a Test model, which has_many questions, and Question, which has_many answers...
When I make a query for a Test with :include => [:questions, {:questions => :answers}] ActiveRecord makes two more queries to fetch the questions and then to fetch the answers - it doesn`t join them!!! When I do the query with :joins ActiveRecord m...
When must we use eager loading in NHibernate? What is it's usage?
...
Assuming the following fictional layout
Dealership
has many Cars
has a Manufacturer
I want to write a query that says get me a Dealership with a Name of X and also get the Cars collection but use a join against the manufacturer when you do so. I think this would require usage of ICriteria. I'm thinking something like this..
...
Two models (Rails 2.3.8):
User; username & disabled properties; User has_one :profile
Profile; full_name & hidden properties
I am trying to create a named_scope that eliminate the disabled=1 and hidden=1 User-Profiles. The User model is usually used in conjunction with the Profile model, so I attempt to eager-load the Profile model...
Hi all, look this code:
// In A.java class
@OneToMany(mappedBy="a", fetch=FetchType.EAGER)
@Cascade(CascadeType.SAVE_UPDATE)
private List<B> bList;
// In B.java class
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="id_a")
@Cascade(CascadeType.SAVE_UPDATE)
private A a;
And this is my record in DB tables.
// Table A
| ID |...
Hi guys,
I have a requirement to load a complex object called Node...well its not that complex...it looks like follows:-
A Node has a reference to EntityType which has a one to many with Property which in turn has a one to many with PorpertyListValue
public class Node
{
public virtual int Id
{
get;
set;
}
...
Hey Everyone,
I've got this really basic table structure:
dbo.tblCategory
dbo.tblQuestion (many to one relationship to tblCategory)
dbo.tblAnswer (many to one relationship to tblQuestion)
So basically, what I'm trying to do is when I load a category, I want to also load all Questions, and all Answers.
Now, I've been able to do this...
Here is an example of my entities that I am trying to return with eager loaded collections.
Mixes
-> Tracks (collection)
-> Tags (collection)
I need to return a paged list of Mixes with eager loaded tracks & tags, without paging it is relativly simple by using the Future<>() function to run multiple queries for the tracks + tags.
Be...
Hi,
Not sure this could fall in performance section as well as model/database section, so here goes....
Let's say I have 3 models:
Movie {
has_one :interest, :as => :resource
}
Song {
has_one :interest, :as => :resource
}
Story {
has_one :interest, :as => :resource
}
and ...
Interest {
belongs_to :resource, :polymorphic => true
}
...
My members will have the ability to customise their profile page with X amount of widgets, each widget displays different data such as a list of music, list of people they are following etc.
Several widgets include:
- List of media they have uploaded
- List of people they are following
- List of people following them
- Html/Text wid...
I have come stuck in optimizing one of my queries...here is my scenario...
I have a domain simular to Twitter where a user can follow other users. So here is a sample of my User model:
User
-> Followers (many-to-many users)
-> Following (many-to-many users)
I now need to return a paged result of users following user 'XYZ', but also...
For example (eagerload/joinedload do the same thing):
session = Session()
parents = session.query(Parent).options(joinedload(Parent.children)).all()
session.close()
print parents[0].children # This works
print parents[0].children[0].parent # This gives a lazy loading error
Adding the following loop before closing the session wo...
I have a table Product. Product is related to ProductDescription in a one-to-many relationship. ProductDescription can have more than one row for each product. It will have multiple rows if there are multiple translations for the description of the product. Product has a many-to-one relationship with Language. Language has a language cod...
This is a spin off from another question I posted a few days ago that was successfully answered but it really didn't get into the underlying issue I was having but wasn't able to express fully in my original query.
I have a table Product. Product is related to ProductDescription in a one-to-many relationship. ProductDescription can have...
I have model called VoteTopic with the following associations
belongs_to :user
belongs_to :category
has_many :comments
has_many :vote_items, :dependent => :destroy
has_many :votes, :through => :vote_items
I use Searchlogic gem to query for @vote_topics in the index action as follows..
scope_procedure :all_approved, lambda {status_equ...
I have a document generator which contains queries for about 200 items at the moment but will likely be upwards of 500 when complete. I've recently noticed that some of the mappings denote lazy loading. This presents a problem for the document generator as it needs access to all of these properties based on which document is being genera...