-->
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.  [ 2 posts ] 
Author Message
 Post subject: Fetching of objects when using a JTree in a rich client
PostPosted: Fri Mar 14, 2008 8:24 pm 
Newbie

Joined: Wed Oct 17, 2007 4:59 pm
Posts: 8
Hi together,
although I've read the threads in this forum, I can't find the best way to solve my current problem.

We've got a rich client (spring rcp) and are trying to display the complex data structure in a JTree.

So far we've used the eager fetching mode, but as the project's elements increased, the performance degrades more and more.

My idea was to switch to lazy loading of the node's children. Now I've read that it would be the best option to use just one session and let this be open the entire lifecycle. Is this right? As I was told, there this approach is dangerous as well, f.e. the session is not thread-safe.

I really can't believe, that there is no best practice for this problem out there.

In my opinion it would be the best way to load the children of a TreeNode once the user clicks on it.

I will post my mapping as well and hope that there are ideas how to cope this challenge.

Thank in advance.

Code:
@Entity
@Table(name = "Feature")
public class Feature extends BaseModel
{
   @Id
   @GeneratedValue
   private Long featureId;

   @Basic
   private String title;
   
   @Basic
   private Integer relevance;
   
   @ManyToOne
   @OnDelete(action=OnDeleteAction.CASCADE)
   @JoinColumn(name="parent", insertable=false, updatable=false)
   private Feature parent;
   
   @OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
   @IndexColumn(name="features_position", base=0)
   @JoinColumn(name="parent")
   private List<Feature> subfeatures;

//getter and setter
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 14, 2008 9:12 pm 
Newbie

Joined: Wed Oct 17, 2007 4:59 pm
Posts: 8
I found a good solution for our case...
If I use the following code, I could increase the speed a lot.

Code:
   @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
   @IndexColumn(name = "features_position", base = 0)
   @JoinColumn(name = "parent")
   @Fetch(FetchMode.SUBSELECT)
   private List<Feature> subfeatures;


So the fetchMode was a good choice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.