-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Performance problem when fetching a large tree
PostPosted: Wed Jan 18, 2006 12:02 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
I have these classes:

Code:
public class Scorecard {
  int id;
  Node topNode; 
}

public class Node {
int id;
Node parent;
IList children; // List of Node
}


The topNode is the top of a tree of Nodes. Each Node can belong only to one Scorecard. I have tried several implementation variants, but it always take several seconds before the tree of 3000 nodes is built.

How should I design my database and mapping files to get a good performance?

/Calle


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 12:46 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Enable lazy loading for class Node. You will need to use properties to access the fields. Make those properties (and any methods) of Node virtual.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 1:18 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
Problem is that most of the tree must be traversed before deciding what the user should see. So I really want it to fetch ALL nodes belonging to that Scorecard and build a tree structure.

How do I do this most effectively? How should the database scheme and mapping look like?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 1:56 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Then you should use a query to tell NH what you want to fetch, but proxying will help avoid loading those objects that you don't need.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.