-->
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: Modelling a Tree Structure, limitting load depth
PostPosted: Fri Jul 15, 2005 6:41 am 
Newbie

Joined: Wed Jun 01, 2005 5:34 am
Posts: 6
Location: Karlsruhe (Germany)
I have Object Rubric that has an 1:n mapping to itself.
When defining this mapping as lazy this will end in the n+1 Problem.
When defining this mapping non lazy, my whole tree is loaded (m selects to the database)
Regarding performance both of these possibilities ar bad.

Is it possible to configure the load depth per session?

Is there another way to load all the sub-rubrics at once, but not the sub-sub-rubrics?





Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version: 3[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 7:00 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
I am using the following approach in my applications:
1. Map almost all relations as lazy
2. When you need deep read (eager fetch in Hibernate terms;) use JOIN FETCH HQL construction

Code:
select p from Parent p
left join fetch p.children c
left join fetch c.friends f
where f.lastName='Leonid Shlyapnikov'

_________________
Leonid Shlyapnikov


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.