-->
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.  [ 3 posts ] 
Author Message
 Post subject: Nested Set / Materilized Path Question
PostPosted: Tue Dec 09, 2008 1:08 pm 
Newbie

Joined: Mon Dec 08, 2008 2:08 pm
Posts: 10
nested set
http://www.developer.com/db/article.php/3517366

materialized path
http://philihp.blogspot.com/2008/05/usi ... trees.html

So i've been reading about these two patterns for optimized tree persistence in a relational DB and i think i'm starting to understand how they work but i have a question...

If i were to implement one of them it would give me a quick way of selecting all of the sub nodes of any location in the hierarchy. But! How do i convince hibernate to organize the instantiated objects as a tree.

What happens is i get a flat list of all of the nodes and if you touch one of the children it queries the DB to load them. Just for the heck of it i tried to manually stuff one of the children into it's parent programatically but that didnt resolve the issue. (it still queried the DB but now i had a duplicate instance of the child object)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 6:29 pm 
Newbie

Joined: Mon Dec 08, 2008 2:08 pm
Posts: 10
I just had an epiphany about this. The 'problem' here is that hibernate tries to read the children because there is a one-to-many mapping to teach hibernate how the hierarchy is structured. If you use a strategy like Materialized Path or Nested Set you still in cure a DB query to find the children because hibernate doesn't know that you found them all by other means. I think that the solution here is to use hibernate the read all of the records for nodes below your chosen node and then use java to associate the instantiated objects. But for this to work without additional db polling i'd also need to remove hibernate collection annotation defining the one-to-many join.

I think that this will work.


Top
 Profile  
 
 Post subject: Re: Nested Set / Materilized Path Question
PostPosted: Wed Jan 19, 2011 12:55 pm 
Newbie

Joined: Fri May 25, 2007 4:37 am
Posts: 13
Location: Germany
I´m very interested in this topic currently.

I came across the same idea of manually handling the relation between objects in Java.

Did you try this or did you come to another solution to the problem?


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