-->
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: Advice on mapping hierarchy
PostPosted: Fri Jul 14, 2006 3:02 pm 
Beginner
Beginner

Joined: Fri May 06, 2005 2:37 pm
Posts: 39
Our system has a fairly deep (5 class) and wide (total of 8 classes) hierarchy that we are trying to map to our database. Our model (at least this part) looks something like this:
Code:
                               *A
                              |  |
                             B   *C
                                | | |
                                D E F
                                    |
                                    G
                                    |
                                    H

(* classes are abstract)

Our current data model is TPS, which maps to 8 tables (obviously). Unfortunately, queries against this model (especially classes F and G) are very unperformant, because of the number of joins required.

We have tried several ways of mapping this structure, all of which lead to their own problems. A full TPH gives us a giant (30 column) table with scores of unrelated data. Trying to use <join> to break out a few classes allows us to get class B out of the giant subclass table, but little else.

Hibernate does not support what we would like to do, which is mix TPS and TPH within a single hierarchy, preferably by combining classes F and G into a single table per hierarchy (possibly with H) while keeping the classes above them split out.

Any advice would be much appreciated. I don't suppose there's any chance of Hibernate expanding its support of mixing TPH and TPS anytime soon?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 8:34 pm 
Beginner
Beginner

Joined: Tue May 23, 2006 4:10 pm
Posts: 38
Location: Charleston, SC
Actually you can mix table per class hierarchy and table per subclass using a slightly modified form with a nested join element. Look in section 9.1.4 of the docs. We completely stayed away from table per subclass because of the performance hit and our domain model is quite complex. We went with TPH and TPC and have been quite pleased with the results. Sure, some of the tables are wide but who cares when hibernate takes care of transforming the records into objects.

Grant


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 3:25 pm 
Beginner
Beginner

Joined: Fri May 06, 2005 2:37 pm
Posts: 39
I wanted to point people to the issue I filed on this topic, HHH-1939.

Any help, suggestions or advice would be appreciated. Thanks to Steve for his initial pointer.


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.