• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

self referencing relationship - many selects from hibernate

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using JPA with hibernate as the provider. I've implemented an entity with a self referencing relationship in order to be
able to do nested categories. When I load the root node, hibernate generates one select for each entity in the tree in order
to load the children. Im beginning to think, by the very nature of this type of tree, that this is unavoidable. can someone confirm?

Here's the mapping:



and here's the query. I just query the root node. Maybe this part is wrong



Here's the data:



and here's what hibernate does.



Too many selects (1 per entity to load all the children)

So, am I doing something wrong?
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Billy,

Since they are all seperate entities, I dont think there is a way around that. However, hibernate should help reduce the impact of all the calls w/ the shared cache and connection pooling.

-Shannon
 
Get off me! Here, read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic