Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Hibernate: Simpler query with many subclasses

 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have object relationship that basically a common entity as the parent with many child classes which specialize with different attribute.
We map those relationship using joined-subclass so parent and each children have their own table.
And there are cases where we would like to query just information that is
available in parent table only. How can we do that? Currently hibernate will
automatically do a join on all the children tables on the query. We are concern on the performance and any limit any database has for the SQL length.

Currently we have close to 40 child tables.

Thanks..
[ September 02, 2004: Message edited by: Wirianto Djunaidi ]
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried to define as the proxy of child class the parent class?

./pope
 
author
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically, there is no really efficient way to handle very deep table-per-subclass mappings in ORM. So we say try to avoid such deep inheritance hierarchies.

However, in Hibernate3, you can use a trick:

http://blog.hibernate.org/cgi-bin/blosxom.cgi/2004/08/25#join

to handle your case (perhaps) more efficiently. There are tradeoffs between this approach and the <joined-subclass> approach. Usually <joined-subclass> is better, since it is less vulnerable to N+1 selects problems.
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic